Set command customization in Blazor Toolbar Component

8 Oct 20211 minute to read

The HtmlAttributes property of the Toolbar item is used to set the HTML attributes (‘ID’, ‘class’, ‘style’ ,’role’) for the commands.

When style attributes are added, if the same attributes were already present, they will be replaced. This is not so in the case of class attribute. Classes will be added to the element instead of replacing the existing ones.

Single or multiple CSS classes can be added to the Toolbar commands using the Toolbar item CssClass property.

@using Syncfusion.Blazor.Navigations

<SfToolbar Width="500">
        <ToolbarItem Text="Bold" Type="ItemType.Button" HtmlAttributes="@Item1"></ToolbarItem>
        <ToolbarItem Text="Italic" Type="ItemType.Button"></ToolbarItem>
        <ToolbarItem Type="ItemType.Button" Text="Underline"></ToolbarItem>
        <ToolbarItem Type="ItemType.Separator"></ToolbarItem>
        <ToolbarItem Text="Uppercase" CssClass="e-txt-casing"></ToolbarItem>

@code {
   Dictionary<string, object> Item1 = new Dictionary<string, object>()
        { "class" , "custom_bold" },
        { "id" , "itemId" }

    .custom_bold .e-tbar-btn-text {
        font-weight: 900;

    .e-txt-casing .e-tbar-btn-text {
        font-variant: small-caps;

Blazor Toolbar with Custom Command