When you first make a Blazor project, the default icon provider is Iconify, with their open icon pack.
How can I change the icon provider?
Most sites provide some JavaScript
to include in an html page, which I don't use since I'm using a Blazor
page.
What do I need to do to switch my provider over?
Blazor Icons Library. The Syncfusion Blazor library provides the set of base64 formatted font icons which are being used in the Syncfusion Blazor components. These icons can be utilized in the web applications using SfIcon component or e-icons class.
This topic applies to Blazor WebAssembly. For general guidance on ASP.NET Core app configuration, see Configuration in ASP.NET Core. Blazor WebAssembly loads configuration from the following app settings files by default: wwwroot/appsettings.json. wwwroot/appsettings.
Don't store app secrets, credentials, or any other sensitive data in the configuration or files of a Blazor WebAssembly app. The following example reads a configuration file ( cars.json) into the app's configuration. The following example uses a MemoryConfigurationSource in Program.cs to supply additional configuration.
In the following example, a UI configuration value is stored in an app settings file and loaded by the Blazor framework automatically. The value is read by a component. Inject an IConfiguration instance into a component to access the configuration data. Pages/ConfigurationExample.razor:
Let’s now learn how to customize our default theme. If you remember, we use the MudThemeProvider component, in the MainLayout.razor file, to make the MudBlazor components work properly. This theme provider provides all the default colors, sizes, shapes, and shadows for material components.
The icons are comming from @import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
from site.css
Import different icons
I have used Material Icons
1.Imported material icon in site.css
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
2.Use the Material Icons
Example:
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<ul class="nav flex-column">
<li class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<i class="material-icons">
accessibility
</i> Home
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<i class="material-icons">autorenew</i>
Counter
</NavLink>
</li>
</ul>
</div>
What worked for is to put the following link on the head tag, then I was able to get the icons
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
then access the icons like so
<i class="material-icons">face</i>
For more info check this document
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With