blazor-docs/knowledge-base/drawer-add-tooltip.md

102 строки
3.0 KiB
Markdown
Исходник Постоянная ссылка Обычный вид История

---
title: Add tooltips to the Drawer items
description: How to add tooltips to the Drawer items.
type: how-to
page_title: Drawer tooltips
slug: drawer-kb-tooltips
position:
tags:
ticketid: 1640720
res_type: kb
---
## Environment
<table>
<tbody>
<tr>
<td>Product</td>
<td>Drawer for Blazor</td>
</tr>
</tbody>
</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.
docs: apply spelling fixes from ReDox report (#2010) * Fix "It is" to "This is" Reported by retext_simplify * Update wcag-section-508-wai-aria.md * Fix typo * Fix typos * Update telerik-datasource-package.md * Update encoding.md * Update buttons.md * Update selection.md * Update overview.md * Update actions.md * Update building-blocks.md * Update overview.md * Update trendlines.md * Update candlestick.md * Update donut.md * Update heatmap.md * Update pie.md * Update selection.md * Update overview.md * Update wai-aria-support.md * Update custom-colors.md * Update presets.md * Update data-bind.md * Update keyboard-typing.md * Update overview.md * Update supported-formats.md * Update events.md * Update spreadsheet.md * Update spreadstream.md * Update templates.md * Update data-bind.md * Update context-menu.md * Update events.md * Update overview.md * Update preview-pane.md * Update search.md * Update sort.md * Update views.md * Update overview.md * Update overview.md * Update validation.md * Update events.md * Update formitemstemplate.md * Update state.md * Update editing.md * Update visible.md * Update width.md * Update editor.md * Update labels.md * Update pointers.md * Update labels.md * Update pointers.md * Update labels.md * Update scale.md * Update overview.md * Update labels.md * Update data-binding.md * Update refresh-data.md * Update sizing.md * Update overview.md * Update single.md * Update editor.md * Update filter.md * Update overview.md * Update events.md * Update selection.md * Update selection.md * Update appearance.md * Update templates.md * Update overview.md * Update mask-prompt.md * Update overview.md * Update navigation.md * Update templates.md * Update overview.md * Update overview.md * Update templates.md * Update refresh-data.md * Update overview.md * Update wai-aria-support.md * Update overview.md * Update data-binding.md * Update overview.md * Update data-bind.md * Update data-bind.md * Update events.md * Update edit-appointments.md * Update appearance.md * Update overview.md * Update overview.md * Update orientation.md * Update indicators.md * Update navigator.md * Update overview.md * Update candlestick.md * Update ohlc.md * Update overview.md * Update wai-aria-support.md * Update icons.md * Update built-in-tools.md * Update position.md * Update template.md * Update overview.md * Update row-drag-drop.md * Update checkbox.md * Update visible.md * Update incell.md * Update checkboxlist.md * Update single.md * Update editor.md * Update filter.md * Update drag-drop.md * Update overview.md * Update multiple.md * Update single.md * Update events.md * Update overview.md * Update buttons.md * Update stepper.md * Update ci-cd-build-server.md * Update troubleshooting.md * Update convert-project-wizard.md * Update localization.md * Update fiddler-jam.md * Update cdn-fallback.md * Update chart-performance-optimization.md * Update combo-debounce-onread.md * Update combobox-clear-button-click.md * Update combobox-not-closing.md * Update common-connection-closed.md * Update common-kb-render-fragment-parameter-null.md * Update common-newtonsoft-breaks-datasourcerequest-serialization.md * Update common-theme-customization-options.md * Update common-wasm-prerendering.md * Update date-input-picker-datetimeoffset.md * Update drawer-add-tooltip.md * Update dropdown-kb-bind-to-enum.md * Update dropdowns-get-model.md * Update editor-add-text-templates.md * Update form-dirty-fields.md * Update grid-aggregates-and-datatable.md * Update grid-bootstrap-flex-width-issue.md * Update grid-conditional-cell-background.md * Update grid-customize-delete-confirmation-dialog.md * Update grid-datasourcerequest-on-server.md * Update grid-detailtemplate-renders.md * Update grid-expand-button-tooltip.md * Update grid-filter-operator-dropdown.md * Update grid-force-refresh.md * Update grid-get-filtered-data.md * Update grid-multiselect-editor.md * Update grid-number-formatting-of-the-csv-export.md * Update grid-persist-selection-across-pages.md * Update grid-sort-descending.md * Update grid-static-group.md * Update grid-wrap-and-center-column-text.md * Update grids-foreign-key.md * Update listview-searchbox.md * Update menu-authorize-view.md * Update multiselect-selected-items-order.md * Update nest-render-fragment.md * Update numerictextbox-scientific-format-small-numbers.md * Update pdfviewer-sign-pdfs.md * Update textarea-autosize-max-height.md * Update textbox-validate-on-change.md * Update treeview-disabled-readonly.md * Update treeview-horizontal-scrollbar.md * Update typescript-exports-error.md * Update window-custom-css-styling.md * Update swatch-distribution.md * Update old-version-support-policy.md * Update 2-0-0.md * Update 3-0-0.md * Update 3-6-0.md * Update 4-3-0.md * Update components/pivotgrid/data-binding.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update knowledge-base/dropdowns-get-model.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> --------- Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com>
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%}).
>caption Add a tooltip to the Drawer navigation icons
````CSHTML
<TelerikTooltip TargetSelector=".k-drawer-items span.icon-container[title]" />
<p>
<TelerikButton OnClick="@ToggleDrawer" Icon="@SvgIcon.Menu">Toggle Drawer</TelerikButton>
</p>
<TelerikDrawer @ref="@DrawerRef"
Data="@DrawerData"
MiniMode="true"
Mode="@DrawerMode.Push">
<ItemTemplate Context="item">
@* 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>
<span class="k-item-text">@item.Text</span>
@* *** *@
@* 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>*@
</ItemTemplate>
</TelerikDrawer>
<style>
.drawer-navlink {
color: inherit;
text-decoration: none;
}
</style>
@code {
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();
}
public class DrawerItem
{
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;
}
}
````