ButtonGroup Icons
You can add a Telerik Font or SVG icon to the ButtonGroup items to illustrate its purpose by using the Icon and EndIcon parameters of ButtonGroupButton and ButtonGroupToggleButton.
The Icon parameter renders a leading icon, before the item text or content. For SVG icons, use IconVariant on each ButtonGroup item to select an available icon variant. See SVG icon variants.
The example below also includes conditional logic to show different icons in the different button states.
Make sure to register
font-icons.cssif using Telerik font icons.
How to use icons in the Telerik ButtonGroup Button
EndIcon Parameter
Use the EndIcon parameter of ButtonGroupButton and ButtonGroupToggleButton to render a trailing icon, after the item text or content. The EndIcon parameter 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. See SVG icon variants.
When a ButtonGroup item has both a leading and a trailing icon, it renders them in the following order: Icon, item text or content, EndIcon.
Make sure to register
font-icons.cssif using Telerik font icons.
How to use a trailing icon in the Telerik ButtonGroup
<TelerikButtonGroup>
<ButtonGroupButton Icon="@SvgIcon.Save"
EndIcon="@SvgIcon.CaretAltRight">
Save
</ButtonGroupButton>
<ButtonGroupToggleButton EndIcon="@FontIcon.Star">
Favorite
</ButtonGroupToggleButton>
</TelerikButtonGroup>
Notes
If you don't add text to the button, the button will center the icon on all sides.
You can also add custom icons and images with additional markup inside the Button content, where the text is.
Images used as icons should generally be small enough to fit in a line of text. The 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
Classon the button that providesheightandwidth. The width and height can be set inpxsufficient to accommodate the icon or toauto, - Attach an
@onclickhandler to an icon/span/imgelement instead of using a button, - Add your own HTML inside the button, something like:
<ButtonGroupButton><img style="width: 400px; height: 400px;" src="my-icon.svg" />some text</ButtonGroupButton>