SplitButton Icons
The <TelerikSplitButton> and <SplitButtonItem> provide an Icon parameter that allows you to add an icon to the main button and all secondary action items.
The Icon parameter type is object and it accepts:
- A property of the static
SvgIconclass - A member of the
FontIconenum - A
stringthat is a CSS class for a custom icon
For SVG icons, use IconVariant on the main button and each SplitButtonItem to select an available variant. See SVG icon variants.
Make sure to register
font-icons.cssif using Telerik font icons.
How to use icons in Telerik Blazor SplitButton
EndIcon Parameter
The <TelerikSplitButton> also provides an EndIcon parameter that renders a trailing icon after the text or content of the main (primary) action button. The EndIcon parameter applies only to the primary action and is not available on SplitButtonItem, which represents the secondary actions in the dropdown.
The EndIcon parameter type is object and it accepts the same value types as Icon:
- A property of the static
SvgIconclass. - A member of the
FontIconenum. - A
stringthat is a CSS class for a custom icon.
For SVG icons, use EndIconVariant to select an available variant for the trailing icon. The EndIconVariant parameter is independent from IconVariant, which applies only to the leading Icon of the primary action. See SVG icon variants.
When the primary action has both a leading and a trailing icon, it renders them in the following order: Icon, button text or content, EndIcon.
Make sure to register
font-icons.cssif using Telerik font icons.
How to use a trailing icon on the primary SplitButton action
<TelerikSplitButton Icon="@SvgIcon.Save"
EndIcon="@SvgIcon.CaretAltRight">
<SplitButtonContent>Save</SplitButtonContent>
<SplitButtonItems>
<SplitButtonItem>Save As</SplitButtonItem>
<SplitButtonItem>Save All</SplitButtonItem>
</SplitButtonItems>
</TelerikSplitButton>
Best Practices for Custom Icons and Images
-
You can add custom icons and images through additional markup inside the
<SplitButtonContent>and<SplitButtonItem>tags. Use this approach for images and font icons that rely on specific rendering. One such example is the Google Material Icons library. -
Images used as icons should generally be small enough to fit in a line of text. The primary button is an inline element and is not designed for large images. If you want to use big icon buttons, consider one of the following options:
- Define a
Classfor the button that providesheightandwidth. The width and height can be set toautoor to a value inpx. When using a static value, it must be sufficient to accommodate the icon. - Adding your own HTML inside the
<SplitButtonContent>, something like:<SplitButtonContent><img style="width: 400px; height: 400px;" src="my-icon.svg" />some text</SplitButtonContent>
- Define a