Skip to content

Commit 41c5a9b

Browse files
Drawer tooltips kb (#69)
* kb(drawer): initial commit of kb for tooltips for the drawer * kb(drawer): updated kb article on tooltips and drawer * chore(kb): changed file name of the drawer kb * chore(kb): updated kb * chore(drawer): minor updates on tooltips kb Co-authored-by: Marin Bratanov <m.bratanov@gmail.com>
1 parent f4814ab commit 41c5a9b

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)