Mr.Gomer
Mr.Gomer

Reputation: 649

Adding CSS to Blazor WebAssembly views

Im doing a web project in Blazor WebAssembly and i want to add a specific CSS file to one of my .razor files but i have no idea on earth how to do it.

The project looks like this. enter image description here

Any one who knows how i add a CSS for ListProducts.razor ?

Upvotes: 5

Views: 14578

Answers (3)

Baskovli
Baskovli

Reputation: 640

If you want css file to be specific to one razor file then create css file in same directory with {razor_file_name}.razor.css.

For you case ListProducts.razor.css

info: Microsoft docs

Upvotes: 10

spacemonki
spacemonki

Reputation: 303

You should already have a premade app.css file located in wwwroot/css/app.css

Add the CSS for your entire app there

Upvotes: -1

Yiyi You
Yiyi You

Reputation: 18209

Here is a working demo:

My wwwroot folder:

enter image description here

.razor file:

<link rel="stylesheet" href="css/bootstrap/bootstrap1.min.css" />
@code {
   ...
}

result: enter image description here

Upvotes: 3

Related Questions