@zendeskgarden/react-tooltips package provides a Tooltip component for showing supplemental information when a user hovers over or focuses on an element. All components require a ThemeProvider at the root of your application.
Installation
Tooltip
Tooltip wraps a single trigger element and shows a floating label on hover or focus. Pass the tooltip text or JSX via the content prop and place your trigger element as the child.
The package also exports Tooltip.Title and Tooltip.Paragraph for structuring rich tooltip content.
Usage
Placement
Control where the tooltip appears relative to its trigger with theplacement prop.
- Top
- Bottom
- Start
- End
'auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'.
Rich content
UseTooltip.Title and Tooltip.Paragraph to build multi-line tooltip content.
Controlled visibility
Manage visibility externally usingisVisible and isInitialVisible.
Tooltip props
The content rendered inside the tooltip. Accepts a string or JSX.
The preferred placement of the tooltip relative to its trigger. Accepts
'auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'end', 'end-top', 'end-bottom', 'start', 'start-top', or 'start-bottom'.Adjusts the padding and font size of the tooltip. Accepts
'small', 'medium', 'large', or 'extra-large'.Specifies the tooltip color scheme. Accepts
'dark' or 'light'.Adds a directional arrow pointing to the trigger element.
Adds a delay in milliseconds before the tooltip opens and closes.
Controls tooltip visibility externally. When set, the component is in controlled mode.
Displays the tooltip on the initial render.
Indicates the tooltip is the primary label for its trigger rather than a supplemental description. When
true, the tooltip content is used as aria-label instead of aria-describedby.A list of fallback placements to try when the preferred placement has insufficient space.
Sets the
z-index of the tooltip.Appends the tooltip to the specified element instead of the default portal target.
Defines the ref key used to position the tooltip on the trigger element.
The trigger element. Must be a single React element.