Tooltip
View as MarkdownA popup that appears when an element is hovered or focused, showing a hint for sighted users.
Features
Permalink to heading "Features"- Opens on hover and focus
- Closes on pointer down or Escape key press
- Supports custom open and close delays
- Supports custom positioning with placement options
- Automatically adjusts position to stay in viewport
<primitives:tooltip.root>
<primitives:tooltip.trigger />
<primitives:tooltip.positioner>
<primitives:tooltip.content>
<primitives:tooltip.arrow />
</primitives:tooltip.content>
</primitives:tooltip.positioner>
</primitives:tooltip.root>
Installation
Permalink to heading "Installation"typo3 ui:add tooltip
Please copy the files manually from GitHub into your project.
Read more about installing Components and Primitives.
Examples
Permalink to heading "Examples"Custom Positioning
Permalink to heading "Custom Positioning"Control where the tooltip appears relative to the trigger.
Open Delay
Permalink to heading "Open Delay"Set a custom delay before the tooltip opens.
Close Delay
Permalink to heading "Close Delay"Set a custom delay before the tooltip closes after the pointer leaves.
Disabled Interaction
Permalink to heading "Disabled Interaction"Prevent the tooltip from opening on hover.
On Icon Buttons
Permalink to heading "On Icon Buttons"Common pattern for icon-only buttons that need accessible labels.
API Reference
Permalink to heading "API Reference"The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.
tooltip.root
Permalink to heading "tooltip.root"Provides tooltip state and context for the composed parts. Renders no wrapper element.
| Name | Description | Required | Default |
|---|---|---|---|
defaultOpen | booleanThe initial open state of the tooltip when rendered. Use when you don't need to control the open state of the tooltip. | No | false |
disabled | booleanWhether the tooltip is disabled. | No | false |
openDelay | integerThe open delay of the tooltip. | No | 400 |
closeDelay | integerThe close delay of the tooltip. | No | 150 |
closeOnPointerDown | booleanWhether to close the tooltip on pointerdown. | No | true |
closeOnEscape | booleanWhether to close the tooltip when the Escape key is pressed. | No | true |
closeOnScroll | booleanWhether the tooltip should close on scroll. | No | true |
closeOnClick | booleanWhether the tooltip should close on click. | No | true |
interactive | booleanWhether the tooltip's content is interactive and remains open when hovered. | No | false |
positioning | arrayThe user provided options used to position the popover content. | No | - |
rootId | stringThe root ID of the component, used for hydration and identification. | No | - |
ids | arrayThe IDs of of the component parts for composition. | No | [] |
autoMount | booleanWhether the client initializes the component on its own. Set it to false to mount it yourself with `mount()` | No | true |
tooltip.trigger
Permalink to heading "tooltip.trigger"Acts as the anchor that opens the tooltip. Renders a <button> element.
| Name | Description | Required | Default |
|---|---|---|---|
value | string | No | - |
attributes | arrayAdditional attributes that should be rendered on the component where ui:attributes is used. | No | [] |
asChild | booleanIf true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props. | No | - |
class | stringThe CSS class(es) to be applied to the component. | No | - |
Rendered data attributes
| Attribute | Description |
|---|---|
data-tooltip-trigger | <uid> |
data-value | The value of the item |
data-current | Present when current |
data-expanded | Present when expanded |
data-state | "open" | "closed" |
tooltip.positioner
Permalink to heading "tooltip.positioner"Positions the tooltip content relative to the trigger. Renders a <div> element.
| Name | Description | Required | Default |
|---|---|---|---|
attributes | arrayAdditional attributes that should be rendered on the component where ui:attributes is used. | No | [] |
asChild | booleanIf true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props. | No | - |
class | stringThe CSS class(es) to be applied to the component. | No | - |
tooltip.content
Permalink to heading "tooltip.content"Displays the tooltip bubble content. Renders a <div> element.
| Name | Description | Required | Default |
|---|---|---|---|
attributes | arrayAdditional attributes that should be rendered on the component where ui:attributes is used. | No | [] |
asChild | booleanIf true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props. | No | - |
class | stringThe CSS class(es) to be applied to the component. | No | - |
Rendered data attributes
| Attribute | Description |
|---|---|
data-tooltip-content | <uid> |
data-state | "open" | "closed" |
data-instant | |
data-placement | The placement of the content |
data-side | The side of the trigger that the content is positioned on |
tooltip.arrow
Permalink to heading "tooltip.arrow"Displays a decorative tooltip arrow. Renders a <div> element.
| Name | Description | Required | Default |
|---|---|---|---|
attributes | arrayAdditional attributes that should be rendered on the component where ui:attributes is used. | No | [] |
asChild | booleanIf true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props. | No | - |
class | stringThe CSS class(es) to be applied to the component. | No | - |
Machine JavaScript API
Permalink to heading "Machine JavaScript API"| Name | Type | Description |
|---|---|---|
open | boolean | Whether the tooltip is open. |
setOpen | (open: boolean) => void | Function to open the tooltip. |
triggerValue | string | null | The trigger value |
setTriggerValue | (value: string | null) => void | Function to set the trigger value |
reposition | (options?: Partial<PositioningOptions>) => void | Function to reposition the popover |
getTriggerState | (props?: TriggerProps) => TriggerState | Returns the state of a specific trigger, including whether it's the currently active one |
getContentState | () => ContentState | Returns the state of the content |
Accessibility
Permalink to heading "Accessibility"| Key | Description |
|---|---|
Tab | Opens/closes the tooltip without delay. |
Escape | If open, closes the tooltip without delay. |