|
| 1 | +--- |
| 2 | +title: Built-in Tools |
| 3 | +page_title: ToolBar - Built-in Tools |
| 4 | +description: Built-in Tools in the Telerik ToolBar for Blazor |
| 5 | +slug: toolbar-built-in-tools |
| 6 | +tags: telerik,blazor,toolbar,builtin,tools,button,buttons |
| 7 | +published: True |
| 8 | +position: 1 |
| 9 | +--- |
| 10 | + |
| 11 | +# Built-in Tools |
| 12 | + |
| 13 | +The Telerik ToolBar for Blazor allows you to use built-in buttons and button groups or to add a [custom tool]({%slug toolbar-templated-item%}). The available built-in tools are: |
| 14 | + |
| 15 | +* [ToolBarButton](#toolbarbutton) |
| 16 | +* [ToolBarToggleButton](#toolbartogglebutton) |
| 17 | +* [ToolbarButtonGroup](#toolbarbuttongroup) |
| 18 | + |
| 19 | +## ToolBarButton |
| 20 | + |
| 21 | +A toolbar button is a plain button that you can click and it raises an event so the application can respond to that. |
| 22 | + |
| 23 | +You can add multiple buttons to the Telerik Toolbar. To do that you should add the `<ToolBarButton>` to the `<TelerikToolBar>`. |
| 24 | + |
| 25 | +You can customize the buttons using the following features: |
| 26 | + |
| 27 | +* `Enabled` - `bool`, defaults to `true` - specifies if the button is clickable. |
| 28 | + |
| 29 | +* `Visible` - `bool`, defaults to `true` - specifies if the button will be visible in the toolbar. |
| 30 | + |
| 31 | +* `Title` - `string` - maps to the `title` HTML attribute for the `<button>`. |
| 32 | + |
| 33 | +* `Class` - `string` - the CSS class that will be rendered on the main wrapping element of the ToolbarButton. You could use that class to cascade styles. |
| 34 | + |
| 35 | +* `OnClick` - `EventCallback` - allows you to execute a method upon the click of the button. For more information see the [Events]({%slug toolbar-events%}) article. |
| 36 | + |
| 37 | +* `Icon` - `string` - adds a font icon to the button. You can find more information on adding a font icon to a Telerik Component in [Telerik Font Icons article]({%slug general-information/font-icons%}#icon-in-telerik-component). |
| 38 | + |
| 39 | +* `ImageURL` - `string` - adds an image to the button. You can provide an image url to this parameter. |
| 40 | + |
| 41 | +* `SpriteClass` - `string` - add a sprite class image to the button. Set this attribute to `k-icon MySpriteClass` where `MySpriteClass` defines the CSS rules for the sprite. |
| 42 | + |
| 43 | +* `IconClass` - `string` - allows you to set a CSS class that provides the required font name, font size and content for the `::before` pseudo-element. |
| 44 | + |
| 45 | +>caption The Telerik ToolBar with ToolBarButtons |
| 46 | +
|
| 47 | + |
| 48 | + |
| 49 | +````CSHTML |
| 50 | +@*This example shows the TelerikToolBar with ToolBarButtons and their features*@ |
| 51 | +
|
| 52 | +<TelerikToolBar> |
| 53 | + <ToolBarButton Icon="@IconName.Bold" Class="myBoldButton" Enabled="@true" Visible="true" Title="Bold Button" OnClick="@OnBold">Bold</ToolBarButton> |
| 54 | + <ToolBarButton Icon="@IconName.Italic" Class="myItalicButton" Enabled="@false" Visible="true" Title="Italic Button" OnClick="@OnItalic">Italic</ToolBarButton> |
| 55 | + <ToolBarButton Icon="@IconName.Underline" Class="myUnderlineButton" Enabled="@true" Visible="true" Title="Underline Button" OnClick="@OnUnderline">Underline</ToolBarButton> |
| 56 | +</TelerikToolBar> |
| 57 | +
|
| 58 | +@code { |
| 59 | + public void OnBold() |
| 60 | + { |
| 61 | + Console.WriteLine("The user clicked on the bold button"); |
| 62 | + } |
| 63 | +
|
| 64 | + public void OnItalic() |
| 65 | + { |
| 66 | + Console.WriteLine("The user clicked on the italic button"); |
| 67 | + } |
| 68 | +
|
| 69 | + public void OnUnderline() |
| 70 | + { |
| 71 | + Console.WriteLine("The user clicked on the underline button"); |
| 72 | + } |
| 73 | +} |
| 74 | +```` |
| 75 | + |
| 76 | +## ToolBarToggleButton |
| 77 | + |
| 78 | +A toolbar toggle button has two states - normal and selected - and clicking it can toggle between them through two-way binding or an event. |
| 79 | + |
| 80 | +You can add multiple toggle buttons to the Telerik Toolbar. To do that you should add the `<ToolBarToggleButton>` to the `<TelerikToolBar>`. |
| 81 | + |
| 82 | +You can customize the toggle buttons using the following features: |
| 83 | + |
| 84 | +* `Selected` - `bool` - specifies whether the button is in selected state. You can use it with one and two-way data binding with the `SelectedChanged` event. For more information on how to handle the `SelectedChanged` event see the [Events]({%slug toolbar-events%}) article. |
| 85 | + |
| 86 | +* `Enabled` - `bool`, defaults to `true` - specifies if the button is clickable. |
| 87 | + |
| 88 | +* `Visible` - `bool`, defaults to `true` - specifies if the button will be visible in the toolbar. |
| 89 | + |
| 90 | +* `Title` - `string` - maps to the `title` HTML attribute for the `<button>`. |
| 91 | + |
| 92 | +* `Class` - `string` - the CSS class that will be rendered on the main wrapping element of the ToolbarButton. You could use that class to cascade styles. |
| 93 | + |
| 94 | +* `OnClick` - `EventCallback` - allows you to execute an method upon the click of the button. For more information read the [Events]({%slug toolbar-events%}) article. |
| 95 | + |
| 96 | +* `Icon` - `string` - adds a font icon to the button. You can find more information on adding a font icon to a Telerik Component in [Telerik Font Icons article]({%slug general-information/font-icons%}#icon-in-telerik-component). |
| 97 | + |
| 98 | +* `ImageURL` - `string` - adds an image to the button. You can provide an image url to this parameter. |
| 99 | + |
| 100 | +* `SpriteClass` - `string` - add a sprite class image to the button. Set this attribute to `k-icon MySpriteClass` where `MySpriteClass` defines the CSS rules for the sprite. |
| 101 | + |
| 102 | +* `IconClass` - `string` - allows you to set a CSS class that provides the required font name, font size and content for the `::before` pseudo-element. |
| 103 | + |
| 104 | +>caption The Telerik ToolBar with ToolBarToggleButtons |
| 105 | +
|
| 106 | + |
| 107 | + |
| 108 | +````CSHTML |
| 109 | +@*This example shows the TelerikToolBar with ToolBarToggleButton and its available features*@ |
| 110 | +
|
| 111 | +<TelerikToolBar> |
| 112 | + <ToolBarToggleButton @bind-Selected="@Selected" |
| 113 | + Enabled="true" |
| 114 | + Class="myToggleFullScreenButton" |
| 115 | + Icon="@IconName.ToggleFullScreenMode" |
| 116 | + OnClick="@ToggleFullScreen"> |
| 117 | + Toggle Fullscreen |
| 118 | + </ToolBarToggleButton> |
| 119 | +</TelerikToolBar> |
| 120 | +
|
| 121 | +@code { |
| 122 | + public bool Selected { get; set; } = true; |
| 123 | +
|
| 124 | + public void ToggleFullScreen() |
| 125 | + { |
| 126 | + if (Selected) |
| 127 | + { |
| 128 | + Console.WriteLine("The user is in full screen"); |
| 129 | + } |
| 130 | + else |
| 131 | + { |
| 132 | + Console.WriteLine("The user exited full screen"); |
| 133 | + } |
| 134 | + } |
| 135 | +} |
| 136 | +```` |
| 137 | + |
| 138 | +## ToolBarButtonGroup |
| 139 | + |
| 140 | +The button group is a container for one or more buttons that renders them together and spaces them out from the adacent buttons or groups. |
| 141 | + |
| 142 | +You can add one or more group of buttons to the Toolbar. To do that you should add the `<ToolBarButtonGroup>` to the `<TelerikToolBar>`. In the button group you can place either the `ToolBarButton` or the `ToolBarToggleButton`. |
| 143 | + |
| 144 | +You can customize the groups using the following features: |
| 145 | + |
| 146 | +* `Visible` - `bool`, defaults to `true` - specifies if the group will be visible in the toolbar. |
| 147 | + |
| 148 | +* `SelectionMode` - `enum` - specifies whether you can select one or multiple buttons from the group at the same time (applicable for `ToolBarToggleButton` instances inside it). It takes a member of the `ButtonGroupSelectionMode` enum: |
| 149 | + |
| 150 | + * Single - this is the default value |
| 151 | + * Multiple |
| 152 | + |
| 153 | +* `Enabled` - `bool`, defaults to `true` - specifies if the group is clickable. |
| 154 | + |
| 155 | +* `Class` - `string` - the CSS class that will be rendered on the main wrapping element of the ToolBarButtonGroup. You could use that class to cascade styles. |
| 156 | + |
| 157 | +* `Width` - `string` - allows you to control the width of the group. |
| 158 | + |
| 159 | +>caption The Telerik ToolBar with grouped buttons |
| 160 | +
|
| 161 | + |
| 162 | + |
| 163 | +````CSHTML |
| 164 | +@*This example shows the TelerikToolBar with grouped ToolBarButtons*@ |
| 165 | +
|
| 166 | +<TelerikToolBar> |
| 167 | + <ToolBarButtonGroup Visible="true" |
| 168 | + SelectionMode="@ButtonGroupSelectionMode.Multiple" |
| 169 | + Class="formattingButtons" |
| 170 | + Enabled="true"> |
| 171 | + <ToolBarButton Icon="@IconName.Bold">Bold</ToolBarButton> |
| 172 | + <ToolBarButton Icon="@IconName.Italic">Italic</ToolBarButton> |
| 173 | + <ToolBarButton Icon="@IconName.Underline">Underline</ToolBarButton> |
| 174 | + </ToolBarButtonGroup> |
| 175 | +</TelerikToolBar> |
| 176 | +```` |
| 177 | + |
| 178 | +## See Also |
| 179 | + |
| 180 | + * [Live Demo: ToolBar Overview](https://demos.telerik.com/blazor-ui/toolbar/overview) |
| 181 | + * [ToolBar Overview]({%slug toolbar-overview%}) |
0 commit comments