Tooltip
Hover and focus hints on four sides.
Installs @floating-ui/react-dom and motion.
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/tooltip.jsonUsage
import { Tooltip } from "@/components/ui/tooltip"
<Tooltip content="Bold ⌘B">
<Button size="icon" aria-label="Bold"><Bold /></Button>
</Tooltip>Examples
Sides
Colors
Pass a palette name or any hex value to color.
On a disabled button
Disabled buttons get no pointer or focus events, so wrap them in a focusable span.
Longer text
Tooltips stay on one line by default. Set a max width and whitespace-normal through className to wrap.
API reference
Other props, including className, go to the tooltip bubble.
| Prop | Type | Default |
|---|---|---|
content | ReactNodeWhat the tooltip says. Keep it short and non-interactive. | None |
children | ReactElementThe trigger. A single element that accepts focus and aria-describedby. | None |
side | "top"Side of the trigger the tooltip appears on. | "top" |
align | "start"Alignment along that side. | "center" |
delay | numberMilliseconds before opening on hover. Focus opens immediately and closing is always immediate. | 300 |
color | NeonColorPalette name or hex. Falls back to --neon-accent, then cyan. | inherited |
disabled | booleanNever opens. | false |
open | booleanControlled open state. | None |
defaultOpen | booleanInitial state when uncontrolled. | false |
onOpenChange | (open: boolean) => voidCalled when the tooltip wants to open or close. | None |
Accessibility
- The trigger gets aria-describedby pointing at the tooltip while it's open.
- Opens on mouse hover and keyboard focus, never on touch, so don't put anything essential in a tooltip.
- Escape, blur, pointer down and leaving the trigger all close it; you can move the pointer onto the tooltip without it closing.
- Flips to the opposite side and shifts along the edge to stay on screen. It renders in a portal (inside the dialog when there is one), so overflow, masks and transforms on its ancestors can't clip it, and it keeps the trigger's color.