2020-05-14 18:41:59 +03:00
---
title: Add tooltips to the Drawer items
2020-07-01 15:10:55 +03:00
description: How to add tooltips to the Drawer items.
2020-05-14 18:41:59 +03:00
type: how-to
page_title: Drawer tooltips
slug: drawer-kb-tooltips
position:
tags:
2024-02-16 14:44:11 +03:00
ticketid: 1640720
2020-05-14 18:41:59 +03:00
res_type: kb
---
## Environment
2024-02-16 14:44:11 +03:00
2020-05-14 18:41:59 +03:00
< table >
2024-02-16 14:44:11 +03:00
< tbody >
< tr >
< td > Product< / td >
< td > Drawer for Blazor< / td >
< / tr >
< / tbody >
2020-05-14 18:41:59 +03:00
< / table >
## Description
I would like to add [Tooltips ]({%slug tooltip-overview%} ) to the [Drawer's ]({%slug drawer-overview%} ) navigation icons.
## Solution
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).
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.
2024-04-01 17:39:12 +03:00
When using an `ItemTemplate` , the Drawer can still [navigate automatically if the `UrlField` parameter is set, or if the Drawer data items have a populated `Url` property ]({%slug drawer-navigation%} ).
2024-02-16 14:44:11 +03:00
2020-05-14 18:41:59 +03:00
>caption Add a tooltip to the Drawer navigation icons
````CSHTML
2024-02-16 14:44:11 +03:00
< TelerikTooltip TargetSelector = ".k-drawer-items span.icon-container[title]" / >
2020-05-14 18:41:59 +03:00
< p >
2024-02-16 14:44:11 +03:00
< TelerikButton OnClick = "@ToggleDrawer" Icon = "@SvgIcon.Menu" > Toggle Drawer< / TelerikButton >
2020-05-14 18:41:59 +03:00
< / p >
2024-02-16 14:44:11 +03:00
< TelerikDrawer @ref ="@ DrawerRef "
Data="@DrawerData"
2020-05-14 18:41:59 +03:00
MiniMode="true"
2024-02-16 14:44:11 +03:00
Mode="@DrawerMode.Push">
2020-05-14 18:41:59 +03:00
< ItemTemplate Context = "item" >
2024-02-16 14:44:11 +03:00
@* When UrlField is set or there is Url property, the Drawer will navigate automatically. *@
< span class = "icon-container" title = "@item.Title" >
< TelerikSvgIcon Icon = "@item.Icon" / >
< / span >
2020-05-14 18:41:59 +03:00
< span class = "k-item-text" > @item.Text< / span >
2024-02-16 14:44:11 +03:00
@* ** * *@
@* When UrlField is not set and there is no Url property, navigate manually with NavLink or NavigationManager. *@
@*< NavLink >
< TelerikSvgIcon Icon = "@item.Icon" / >
< / NavLink >
< NavLink class = "k-item-text drawer-navlink" >
< span > @item.Text< / span >
< / NavLink > *@
2020-05-14 18:41:59 +03:00
< / ItemTemplate >
< / TelerikDrawer >
2024-02-16 14:44:11 +03:00
< style >
.drawer-navlink {
color: inherit;
text-decoration: none;
}
< / style >
2020-05-14 18:41:59 +03:00
@code {
2024-02-16 14:44:11 +03:00
private TelerikDrawer< DrawerItem > ? DrawerRef { get; set; }
private IEnumerable< DrawerItem > DrawerData { get; set; } = new List< DrawerItem >
{
new DrawerItem { Title="Counter Title", Text = "Counter", Icon = SvgIcon.Plus, Url = "counter" },
new DrawerItem { Title="FetchData Title", Text = "FetchData", Icon = SvgIcon.GridLayout, Url = "fetchdata" },
};
private async Task ToggleDrawer()
{
await DrawerRef?.ToggleAsync();
}
2020-05-14 18:41:59 +03:00
public class DrawerItem
{
2024-02-16 14:44:11 +03:00
public string Title { get; set; } = string.Empty;
public string Text { get; set; } = string.Empty;
public ISvgIcon? Icon { get; set; }
public string Url { get; set; } = string.Empty;
2020-05-14 18:41:59 +03:00
}
}
````