I want to use additional icons in the NavMenu.razor
in my Blazor 8 application. In Blazor 7 there was a iconset configured in wwwroot/css/
, and so I was able to use additional icons only with naming it in the NavMenu.razor
. But the whole css folder is missed in the Blazor 8 template. There are only three icons configured in the NavMenu.razor.css
, but I don’t know how to add additional icons there.
I’m not a css expert (really not :-() and I don’t know how to solve this problem without my (missing) css knowledge. Is it possible to get new icons likely easily like in Blazor 7?
2
Answers
Thanks to the comment of Kurt I found a solution. I do not use the standard icons anymore, but the icons from a linked library, Blazorise.Icons.FontAwesome (https://blazorise.com/docs/extensions/icons) in my case. This way I changed a nav point in
NavMenu.razor
:All possible icons are found even in the documentation.
I don't know how to use some more standard icons like the three from the template (that's why this response should not be the correct answer), but with an another library I can use more icons like demanded.
Yes, that is possible.
But be aware that this might increase your user’s download considerably.
In App.razor, add
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
In NavMenu.razor, remove (3x) the
-nav-menu
tail fom the icon names (ie, justbi-house-door-fill
)in NavMenu.razor.css, remove the 3 old incons.
in NavMenu.razor.css, in the
.bi
class, settop: -0.75rem;
That last one is a quick fix for aligning the icons, you may want to fine-tune that class a little better.