Button Icons
You can add a Telerik Font or SVG icon to the Button to illustrate its purpose by using the Icon and EndIcon parameters.
Icon Parameter
The Icon parameter renders a leading icon, before the Button text or content. The parameter is of type 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 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 Button
EndIcon Parameter
The EndIcon parameter renders a trailing icon, after the Button text or content. 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. See SVG icon variants.
When the Button 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 in Telerik Button
<TelerikButton Icon="@SvgIcon.Plus"
EndIcon="@SvgIcon.CaretAltRight">
Add Item
</TelerikButton>
<TelerikButton EndIcon="@FontIcon.Download">
Download
</TelerikButton>
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:
<TelerikButton><img style="width: 400px; height: 400px;" src="my-icon.svg" />some text</TelerikButton>