Skip to content

Commit ef4c5ef

Browse files
965796: Dynamic target documentation for tooltip component
1 parent 5caea44 commit ef4c5ef

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

blazor-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4883,6 +4883,7 @@
48834883
</li>
48844884
<li> <a href="/blazor/tooltip/setting-dimension">Setting Dimension</a></li>
48854885
<li> <a href="/blazor/tooltip/content">Content</a></li>
4886+
<li> <a href="/blazor/tooltip/target">Target</a></li>
48864887
<li> <a href="/blazor/tooltip/position">Position</a></li>
48874888
<li> <a href="/blazor/tooltip/open-mode">Open Mode</a></li>
48884889
<li> <a href="/blazor/tooltip/customization">Customization</a></li>
159 KB
Loading

blazor/tooltip/images/target.png

5.2 KB
Loading

blazor/tooltip/target.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
layout: post
3+
title: Target support in Blazor Tooltip Component | Syncfusion
4+
description: Checkout and learn here all about setting target elements in the Syncfusion Blazor Tooltip component, and explore built-in support for displaying Tooltips on elements added dynamically after the initial render and more.
5+
platform: Blazor
6+
control: Tooltip
7+
documentation: ug
8+
---
9+
10+
# Target
11+
12+
The [`Target`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Popups.SfTooltip.html#Syncfusion_Blazor_Popups_SfTooltip_Target) property specifies the target selector where the Tooltip needs to be displayed. It enables Tooltip activation on specific DOM elements based on user interactions like hover or focus.
13+
14+
```cshtml
15+
<SfTooltip Content="Let's go green to save the planet!!" Target="#btn" >
16+
<SfButton ID="btn" Content="Show Tooltip"></SfButton>
17+
</SfTooltip>
18+
```
19+
20+
![Blazor Tooltip Target](images/target.png)
21+
22+
## Displaying Tooltip for dynamically created target element
23+
24+
The Tooltip component can be configured to display Tooltips for elements that are added to the DOM after the initial page load. This behavior is useful in applications where target is rendered dynamically, such as in response to user actions, API calls, or conditional logic.
25+
26+
Set the [`TargetContainer`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Popups.SfTooltip.html#Syncfusion_Blazor_Popups_SfTooltip_TargetContainer) property using a CSS selector that defines the container in which Tooltip target elements will be automatically display Tooltips. All elements inside this container that match the Target selector will automatically show Tooltips, including those added after the component is rendered—no extra setup needed.
27+
28+
```cshtml
29+
@using Syncfusion.Blazor.Popups
30+
@using Syncfusion.Blazor.Buttons
31+
32+
<SfTooltip ID="BasicTooltip" Target="[title]" TargetContainer=".tooltip-container">
33+
</SfTooltip>
34+
<div class="tooltip-container">
35+
<span title="Static tooltip">Static Element</span>
36+
<SfButton @onclick="AddElement">Add Dynamic Element<SfButton>
37+
@if (ShowElement)
38+
{
39+
<span title="Dynamic tooltip">Dynamic Element</span>
40+
}
41+
</div>
42+
43+
@code {
44+
private bool ShowElement = false;
45+
46+
private void AddElement()
47+
{
48+
ShowElement = true;
49+
}
50+
}
51+
```
52+
53+
The [`TargetContainer`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Popups.SfTooltip.html#Syncfusion_Blazor_Popups_SfTooltip_TargetContainer) property enables automatic Tooltip registration for newly added elements, enhancing dynamic content interactivity.
54+
55+
![Blazor Tooltip with Dynamic Targets](images/dynamic-target.gif)

0 commit comments

Comments
 (0)