<link rel="stylesheet" rel='nofollow' href="css/fontawesome/all.min.css" />
private readonly List<object> _gridToolbarItems = new List<object> { new ItemModel { Id = "Add-NRP", Text = "Add NRP", PrefixIcon = "e-add", TooltipText = "Non-Rad Project" }, new ItemModel { Id = "Merge-Projects", Text = "Merge", PrefixIcon = "e-merge", TooltipText = "Merge selected projects to Rad Project" } };
How do I use Font Awesome icons?
<SfGrid DataSource="@Orders" @ref="Grid" AllowGrouping="true" AllowPaging="true" Height="200" Toolbar="_gridToolbarItems">
...
</SfGrid>
@code{
SfGrid<Order> Grid;
public List<Order> Orders { get; set; }
...
private readonly List<object> _gridToolbarItems = new List<object>
{
new ItemModel { Id = "Add-NRP", Text = "Add NRP", PrefixIcon = "fa fa-download", TooltipText = "Non-Rad Project" },
new ItemModel { Id = "Merge-Projects", Text = "Merge", PrefixIcon = "fa fa-binoculars", TooltipText = "Merge selected projects to Rad Project" }
};
}
|
Hi there
i faced some similar issues around the Font Awesome in ToolbarItems, and i found the cause
The reason why some Font awesome icons work and some don't is the e-icons class.
if you add a icon css class to toolbaritmes like your expamles above, follwing code will created:
<span class="fa fa-binoculars e-icons e-btn-icon e-icon-left"></span>
so theres no problem but if you try this for example: PrefixIcon="fa fa-sign-in", the result will be rubbish.
Html: <span class="fa fa-sign-in e-icons e-btn-icon e-icon-left"></span>
Because of e-icons class is priorise their own font-family "e-icons" and in this font-family the "fa-sign-in" doesnt exist.
the only chance to workaround this behavior is to set the font awesome classes as important like this.
.fad { font-family: "Font Awesome 5 Duotone" !important;}
.fa, .fas, .fal {font-family: 'Font Awesome 5 Pro' !important;}
.fal {font-weight: 300 !important;}
.fa, .fas, .fad {font-weight: 900 !important;}
Now Font Awesome has the higher priority. Its not perfect, but it works.
FWY: my theme is tailwind-dark, i tested no other themes to this behavior.
I hope this helped on other issues or queries about Font Awesome.
Regards
Stefan