|
| 1 | +--- |
| 2 | +title: Add tooltips to the Drawer items |
| 3 | +description: How to add tooltips to the Drawer items |
| 4 | +type: how-to |
| 5 | +page_title: Drawer tooltips |
| 6 | +slug: drawer-kb-tooltips |
| 7 | +position: |
| 8 | +tags: |
| 9 | +res_type: kb |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | +<table> |
| 14 | + <tbody> |
| 15 | + <tr> |
| 16 | + <td>Product</td> |
| 17 | + <td>Drawer for Blazor</td> |
| 18 | + </tr> |
| 19 | + </tbody> |
| 20 | +</table> |
| 21 | + |
| 22 | + |
| 23 | +## Description |
| 24 | + |
| 25 | +I would like to add [Tooltips]({%slug tooltip-overview%}) to the [Drawer's]({%slug drawer-overview%}) navigation icons. |
| 26 | + |
| 27 | + |
| 28 | +## Solution |
| 29 | + |
| 30 | +To add a tooltip to the drawer navigation icons you have to use the [ItemTemplate]({%slug drawer-templates%}#itemtemplate) to set a `title` attribute to the desired element (like the `span` that contains the icon). |
| 31 | + |
| 32 | +If using a [TelerikTooltip](https://demos.telerik.com/blazor-ui/tooltip/overview), add a suitable CSS selector, which targets the span with the icon, to the `TargetSelector` parameter of the component. |
| 33 | + |
| 34 | +>caption Add a tooltip to the Drawer navigation icons |
| 35 | +
|
| 36 | +````CSHTML |
| 37 | +@* Add a Telerik Tooltip to the Drawer *@ |
| 38 | +
|
| 39 | +<TelerikTooltip TargetSelector=".k-drawer-items span.k-icon[title]" /> |
| 40 | +
|
| 41 | +<p> |
| 42 | + <TelerikButton OnClick="@(() => DrawerRef.ToggleAsync())" Icon="@IconName.Menu">Toggle drawer</TelerikButton> |
| 43 | +</p> |
| 44 | +
|
| 45 | +<TelerikDrawer Data="@Data" |
| 46 | + MiniMode="true" |
| 47 | + Mode="@DrawerMode.Push" |
| 48 | + @ref="@DrawerRef"> |
| 49 | + <ItemTemplate Context="item"> |
| 50 | + <span class="k-icon k-i-@item.Icon" title="@item.Title"></span> |
| 51 | + <span class="k-item-text">@item.Text</span> |
| 52 | + </ItemTemplate> |
| 53 | +</TelerikDrawer> |
| 54 | +
|
| 55 | +
|
| 56 | +
|
| 57 | +@code { |
| 58 | + public TelerikDrawer<DrawerItem> DrawerRef { get; set; } |
| 59 | + public IEnumerable<DrawerItem> Data { get; set; } = |
| 60 | + new List<DrawerItem> |
| 61 | + { |
| 62 | + new DrawerItem { Title="Counter Title", Text = "Counter", Icon = IconName.Plus, Url = "counter" }, |
| 63 | + new DrawerItem { Title="FetchData Title", Text = "FetchData", Icon = IconName.GridLayout, Url = "fetchdata" }, |
| 64 | + }; |
| 65 | +
|
| 66 | + public class DrawerItem |
| 67 | + { |
| 68 | + public string Title { get; set; } |
| 69 | + public string Text { get; set; } |
| 70 | + public string Icon { get; set; } |
| 71 | + public string Url { get; set; } |
| 72 | + } |
| 73 | +} |
| 74 | +```` |
| 75 | + |
0 commit comments