Overview
A tooltip provides contextual information or labels for UI elements on hover or focus.Features
- Provider to control display delay globally
- Opens when the trigger is focused or hovered
- Closes when the trigger is activated or when pressing Esc
- Supports custom timings
- Ignores hovering on touch devices
Installation
Anatomy
Import all parts and piece them together.API Reference
Provider
Wraps your app to provide global settings for tooltips.The duration from when the mouse enters a tooltip trigger until the tooltip opens.
How much time a user has to enter another trigger without incurring a delay again.
When
true, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.Root
Contains all the parts of a tooltip.The controlled open state of the tooltip. Must be used in conjunction with
onOpenChange.The open state of the tooltip when it is initially rendered. Use when you do not need to control its open state.
Event handler called when the open state of the tooltip changes.
Override the duration given to the Provider to customize the open delay for a specific tooltip.
When
true, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.Trigger
The button that toggles the tooltip.Change the default rendered element for the one passed as a child, merging their props and behavior.
Portal
When used, portals the content part into thebody.
Specify a container element to portal the content into.
Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
Content
The component that pops out when the tooltip is open.Change the default rendered element for the one passed as a child, merging their props and behavior.
By default, screen readers will announce the content inside the tooltip. Use this when you want to announce something different.
The preferred side of the trigger to render against when open.
The distance in pixels from the trigger.
The preferred alignment against the trigger. May change when collisions occur.
An offset in pixels from the “start” or “end” alignment options.
When
true, overrides the side and align preferences to prevent collisions with boundary edges.The element used as the collision boundary. By default this is the viewport.
The distance in pixels from the boundary edges where collision detection should occur.
The sticky behavior on the align axis.
partial will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst always will keep the content in the boundary regardless.Whether to hide the content when the trigger becomes fully occluded.
Event handler called when the escape key is down. It can be prevented by calling
event.preventDefault.Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling
event.preventDefault.Arrow
An optional arrow element to render alongside the tooltip.Change the default rendered element for the one passed as a child, merging their props and behavior.
The width of the arrow in pixels.
The height of the arrow in pixels.
Example
Accessibility
Adheres to the Tooltip WAI-ARIA design pattern.Keyboard Interactions
Tab- Opens the tooltip when the trigger receives keyboard focusSpace- Opens the tooltip without closing when keyboard users activate the triggerEnter- Opens the tooltip without closing when keyboard users activate the triggerEsc- Closes the tooltip
Tooltips are automatically dismissed when the user activates the trigger, unless using keyboard navigation.