Tooltip

The <FluentTooltip> component is used to provide extra information about another element when it is hovered.

<FluentTooltip> wraps the <fluent-tooltip> element, a web component implementation of a tooltip composition leveraging the Fluent UI design system.

Using Tooltip Service Provider

We advise you to always use this service when working with tooltips so all definitions will be generated with global options and will be written at the end of the HTML page to support different z-index levels.

Also, the later described option on having a tooltip appear on a click event will only work when using the Tooltip Service Provider.

In the Program.cs, inject the Tooltip service with global options. You can also use the Services.AddFluentUIComponents method to register all required FluentUI services, including this one.

builder.Services.AddScoped<ITooltipService, TooltipService>();

At the end of your MainLayout.razor page, include the provider:

<FluentTooltipProvider />

For the <FluentTooltipProvider/> to work properly, it needs interactivity! If you are using "per page" interactivity, make sure to add a @rendermode to either the provider itself or the component the provider is placed in.


Example
Tooltip without service
Example of tooltip

Tooltip using TooltipService


Examples

Default

Move your mouse over this icon to display a tooltip.
Example
Download: 

Large tooltip

Move your mouse over this icon to display a very large tooltip.
Example
Download: 

Different delays

Hover one of the buttons to have a tooltip appear on hover at the position mentioned.
Unlike the other tooltip examples, these contain the HideTooltipOnCursorLeave attribute. which hides the tooltip when the cursor leaves (i.e. not hovering) its anchor (even when the cursor hovers the tooltip itself).
Example
Tooltip at the start Tooltip at the top Tooltip at the end
Download: 

Always visible

Example
Click me to toggle tooltip visibility
I'm helping!
Download: 

Documentation

FluentTooltip Class

Parameters

Name
Type
Default
Description
Anchorstring
Required. Gets or sets the control identifier associated with the tooltip.
AutoUpdateModeAutoUpdateMode?
Controls when the tooltip updates its position, default is anchor which only updates when
the anchor is resized. Auto will update on scroll/resize events.
Corresponds to anchored-region auto-update-mode.
ChildContentRenderFragment?
Gets or sets the content to be rendered inside the component.
Delayint?
300
Gets or sets the delay (in milliseconds).
Default is 300.
HideTooltipOnCursorLeavebool?
Gets or sets the value indicating whether the library should close the tooltip if the cursor leaves the anchor and the tooltip.
By default, the tooltip closes if the cursor leaves the anchor, but not the tooltip itself.
You can configure this behavior globally using the LibraryConfiguration.HideTooltipOnCursorLeave property.
HorizontalViewportLockbool
False
Gets or sets whether the horizontal viewport is locked.
MaxWidthstring?
Gets or sets the maximum width of tooltip panel.
PositionTooltipPosition?
Gets or sets the tooltip's position. See TooltipPosition.
Don't set this if you want the tooltip to use the best position.
UseTooltipServicebool
True
Use ITooltipService to create the tooltip, if this service was injected.
If the FluentTooltip.ChildContent is dynamic, set this to false.
Default, true.
VerticalViewportLockbool
False
Gets or sets whether the vertical viewport is locked.
Visiblebool
False
Gets or sets a value indicating whether the tooltip is visible.

EventCallbacks

Name
Type
Description
OnDismissedEventCallback<EventArgs>
Callback for when the tooltip is dismissed.
Example of tooltip
Hello World
It is a small tooltip.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
I'm helping (very quick)!
I'm helping (quick)!
I'm helping (slow)!
Anchor
Auto
Top
Bottom
Left
Right
Start
End
An error has occurred. This application may no longer respond until reloaded. Reload 🗙