Tooltip
A small floating label that appears on hover or focus to describe an element.
Import
import { Tooltip } from '@matix/components/tooltip';Usage
Without Arrow
The arrow is shown by default. Set arrow={false} on Tooltip.Popup to hide it.
Custom Delay
Adjust delay and closeDelay on Tooltip.Root to control timing. Defaults are delay={200} and closeDelay={0}.
<Tooltip.Root delay={0}>
<Tooltip.Trigger>Instant</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Positioner>
<Tooltip.Popup>No delay</Tooltip.Popup>
</Tooltip.Positioner>
</Tooltip.Portal>
</Tooltip.Root>
<Tooltip.Root delay={1000}>
<Tooltip.Trigger>Slow</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Positioner>
<Tooltip.Popup>1 second delay</Tooltip.Popup>
</Tooltip.Positioner>
</Tooltip.Portal>
</Tooltip.Root>Placement
Control positioning via the side and align props on Tooltip.Positioner.
Custom Styles
Use the sx prop on Tooltip.Popup to override styles.
import * as stylex from '@stylexjs/stylex';
const custom = stylex.create({
popup: { backgroundColor: '#1a1a2e', color: '#eaeaea', borderRadius: '8px' },
});
<Tooltip.Root>
<Tooltip.Trigger>Styled tooltip</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Positioner>
<Tooltip.Popup sx={custom.popup}>Custom styled tooltip</Tooltip.Popup>
</Tooltip.Positioner>
</Tooltip.Portal>
</Tooltip.Root>;Server Components
Tooltip is a client component. A Server Component cannot read a property of a client component, so Tooltip.Root is undefined there. In a Server Component, import the named parts. Each Tooltip.<Part> is also exported as Tooltip<Part>.
import {
TooltipRoot,
TooltipTrigger,
TooltipPortal,
TooltipPositioner,
TooltipPopup,
} from '@matix/components/tooltip';In a client component, both forms work.
API Reference
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
Tooltip.Root | open | boolean | — | Controlled open state |
Tooltip.Root | onOpenChange | (open: boolean) => void | — | Called when the open state changes |
Tooltip.Root | delay | number | 200 | Milliseconds to wait before showing the tooltip |
Tooltip.Root | closeDelay | number | 0 | Milliseconds to wait before hiding the tooltip |
Tooltip.Trigger | — | — | — | The element that triggers the tooltip on hover/focus |
Tooltip.Portal | container | HTMLElement | document.body | Portal target |
Tooltip.Positioner | side | 'top' | 'right' | 'bottom' | 'left' | 'top' | Preferred side |
Tooltip.Positioner | align | 'start' | 'center' | 'end' | 'center' | Alignment along the side |
Tooltip.Popup | arrow | boolean | true | Show arrow pointer toward the trigger |
Tooltip.Popup | sx | StyleXStyles | — | StyleX style override |
All sub-components forward additional props to their underlying Base UI elements.
Accessibility
- Built on Base UI
Tooltip. - The tooltip is visual only. Screen readers do not announce it. Give the trigger its own accessible name, for example
aria-labelon anIconButton. - Shows on hover and focus, hides on blur and pointer leave.
- The pointer can move onto the tooltip without closing it (WCAG 1.4.13).
- Not interactive -- tooltips contain only text, no focusable elements.
Keyboard
| Key | Action |
|---|---|
Escape | Closes the tooltip |
Tab (to trigger) | Shows the tooltip via focus |
Tab (away) | Hides the tooltip via blur |