Tooltip
Features
- Opens when the trigger is focused or hovered.
- Closes when the trigger is activated or when pressing escape.
When to use
See our design pattern around overlays to learn why and when you should use this component.
Examples
Using the aria-label
prop
In rare cases the trigger might contain information that is relevant to the user, like a badge showing the count for notifications. In these cases we want the screen reader user to know both the content in the tooltip, but also the content in the badge. For screen reader users, the only content announced to them is whatever is in the tooltip. For these cases, use the aria-label
prop.
Displaying tooltips for disabled buttons
If you are using our Button component, you can see more about disabled states and tooltips here
Disabled buttons do not fire events, so to display a tooltip in this case, you'll have to:
- Render the Trigger as
span
ordiv
. - Ensure the
button
has nopointerEvents
.
const StyledButton = styled(Button)`pointer-events: none;`<Tooltip content="Good job!">{/* tabIndex={0} makes the element focusable */}<div tabIndex={0}><StyledButton disabled>…</StyledButton></div></Tooltip>
Changing the position or alignment of the tooltip
Use these options if the tooltip would otherwise overlay important information. For consistency, the default positioning of top
should be preferred and center
in the case of the alignment.
Best practices
Accessibility
Adheres to the WAI-ARIA practices for tooltips. See Radix documentation for details.
Related components
- Feature tip: Used to help users learn about new or unfamiliar interface features.
- Help popover: An icon button with a question mark that reveals help information on click or tap.
- Icon button: Enables users to control the visibility of other UI elements.
- Popover: A small overlay that opens on demand. Popovers allow users to access additional content and actions without cluttering the page.