Blazorise Icons component
Icons are visual symbols that represent actions, states, or navigation options.
Blazorise ships with multiple icon providers and supports registering custom icon libraries.
To use the Icon component, install one of the Blazorise.Icons.* packages first.
Installation
Install an icon provider package from NuGet.
NuGet
Install extension from NuGet.Install-Package Blazorise.Icons.Bootstrap or Install-Package Blazorise.Icons.AntDesign or Install-Package Blazorise.Icons.FluentUI or Install-Package Blazorise.Icons.FontAwesome or Install-Package Blazorise.Icons.Lucide or Install-Package Blazorise.Icons.Material
Now based on the icon library you want to use, you will need to setup the CSS files.
AntDesign Icons CSS
Note: If you use AntDesign icons, defineblazorise.icons.antdesign.css in your index.html or _Layout.cshtml / _Host.cshtml file.
<link href="_content/Blazorise.Icons.AntDesign/blazorise.icons.antdesign.css?v=2.1.0.0" rel="stylesheet" />
Bootstrap Icons CSS
Note: If you use Bootstrap icons, definebootstrap-icons.min.css in your index.html or _Layout.cshtml / _Host.cshtml file. This file is required for some custom icon styles to work.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css?v=2.1.0.0">
Fluent Icons CSS
Note: If you use Fluent icons, defineFluentSystemIcons-Resizable.css in your index.html or _Layout.cshtml / _Host.cshtml file. This file is required for some custom icon styles to work.
<link href="_content/Blazorise.Icons.FluentUI/FluentSystemIcons-Resizable.css?v=2.1.0.0" rel="stylesheet" />
Font Awesome Icons CSS
Include CSS link into yourindex.html or _Layout.cshtml / _Host.cshtml file, depending if you're using a Blazor WebAssembly or Blazor Server side project.
<link href="_content/Blazorise.Icons.FontAwesome/v6/css/all.min.css?v=2.1.0.0" rel="stylesheet">
Material Icons CSS
Note: If you use Material icons, defineblazorise.icons.material.css in your index.html or _Layout.cshtml / _Host.cshtml file. This file is required for some custom icon styles to work.
<link href="_content/Blazorise.Icons.Material/blazorise.icons.material.css?v=2.1.0.0" rel="stylesheet" />
Lucide Icons CSS
Note: If you use Lucide icons, defineblazorise.icons.lucide.css in your index.html or _Layout.cshtml / _Host.cshtml file.
<link href="_content/Blazorise.Icons.Lucide/blazorise.icons.lucide.css?v=2.1.0.0" rel="stylesheet" />
Registrations
Register the icon provider that matches the package you installed, such asAddFontAwesomeIcons or AddLucideIcons.
builder.Services
.AddBlazorise()
.AddBootstrapProviders()
+ .AddFontAwesomeIcons();
Basic Example
The most basic example of using an icon is to use theIcon component. You can set the icon name using the IconName property.
<Icon Name="IconName.Mail" />
Custom
You can also use a real icon name instead of predefined enum. Note that this is not the preferred way of using icons, but it can be useful in some cases.<Icon Name="@("fa-phone")" />
Icon Names
Preferred way to define icon is to use an enumIconName. That way every icon will be applied automatically based on the icon package that you're using.
In case you cannot find an icon in the provided enum, you can also use prebuilt list of icon names that comes with every icon package. For example for Ant Design you would use AntDesignIcons, for font-awesome you would use FontAwesomeIcons, for material that would be MaterialIcons, while for Lucide that would be LucideIcons.
<Icon Name="Blazorise.Icons.FontAwesome.FontAwesomeIcons.Voicemail" />
Style
Blazorise exposes common icon styles throughIconStyle. To change it you can use one of the supported styles:
- Solid
- Regular
- Light
- DuoTone
<Icon Name="IconName.Mail" IconStyle="IconStyle.Regular" />
Style support
The table below compares how the built-in icon providers handleIconStyle values.
| Provider | Solid | Regular | Light | DuoTone | Notes |
|---|---|---|---|---|---|
| AntDesign | Supported | Supported | Not supported | Supported | Uses AntDesign icon themes. |
| Bootstrap Icons | Single style only | Not supported | Not supported | Not supported | IconStyle does not change the rendered icon. |
| Fluent UI | Supported | Supported | Not supported | Not supported | Predefined icons switch between regular and filled variants. |
| Font Awesome | Supported | Supported | Requires matching Font Awesome assets | Requires matching Font Awesome assets | Support depends on the Font Awesome CSS and font files loaded by the app. |
| Material Icons | Supported | Supported | Supported | Supported | Maps Blazorise styles to Material icon font families. |
| Lucide | Single style only | Single style only | Not supported | Not supported | Lucide is a single outline SVG icon set. |
Size
You can set the size to one of the supported below.
ExtraSmall
Small
Large
x2
x3
x4
x5
x6
x7
x8
x9
x10
<Div Flex="Flex.Row.Wrap.JustifyContent.Start.AlignItems.Start"> @foreach ( var iconSize in Enum.GetValues<IconSize>() ) { @if ( iconSize == IconSize.Default ) continue; <Div Flex="Flex.Column.JustifyContent.Center"> <Span Flex="Flex.JustifyContent.Center.AlignItems.Center" Padding="Padding.Is5"> <Icon Name="IconName.Camera" IconSize="" /> </Span> <Text TextAlignment="TextAlignment.Center"> @iconSize </Text> </Div> } </Div>
Global options
Defining styles on each icon can become very tedious with time. That's why we give you an option to specify them globally. This way, you will have consistent styling across the application, and you can still override them on the icon if you need to.
services.AddBlazorise( options =>
{
options.IconStyle = IconStyle.Light;
options.IconSize = IconSize.Small;
} );
API
Parameters
| Parameter | Description | Type | Default |
|---|---|---|---|
IconSize |
Defines the icon size. |
IconSize? | null |
IconStyle |
Suggested icon style. |
IconStyle? | null |
Name |
Icon name that can be either a string or IconName. |
object | null |
Events
| Event | Description | Type |
|---|---|---|
Clicked |
Occurs when the icon is clicked. |
EventCallback<MouseEventArgs> |
MouseOut |
Occurs when the mouse has left the icon area. |
EventCallback<MouseEventArgs> |
MouseOver |
Occurs when the mouse has entered the icon area. |
EventCallback<MouseEventArgs> |