Skip to content

React Tooltip

A glass React tooltip that appears on hover and keyboard focus; inside a provider, moving between tooltips is instant. Use Tooltip as a glass tooltip to name an icon-only toolbar button on hover or focus, such as Bold or Export, adding the shortcut in the text when there is one.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tooltip.json

Format text

Icon toolbar

Files to copy

4 folders · 4 files · 4 packages
From theme/src/
  • components/tooltip/
  • hooks/use-controllable.ts
  • lib/{cn.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tooltip.jsonRegistry item: tooltip. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/button/
  • components/spinner/
  • hooks/{use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{form.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Sides and delay

side picks the edge it opens on. delay is how long the pointer must rest before it opens; 0 shows it at once. A TooltipProvider makes moving between tooltips instant.

Props

PropTypeDefaultDescription
content (required)ReactNodeNoneWhat the tooltip says.
children (required)ReactElement<unknown, string | JSXElementConstructor<any>>NoneThe element that shows the tooltip on hover, keyboard focus or (touch) a long press. Must accept a ref (a native element or a SheenUI component).
side"top" | "bottom" | "left" | "right""top"Which side of the trigger it opens on. It flips when there is no room.
align"center" | "end" | "start""center"Alignment along that side: "start", "center" or "end".
delaynumber300Sets the delay before showing, in ms.
openbooleanNoneOpen state (controlled). Pair with onOpenChange. Leave it out to let hover, focus and touch decide.
defaultOpenbooleanfalseStarting open state when uncontrolled.
onOpenChange((open: boolean) => void)NoneCalled when the tooltip wants to open or close (hover, focus, Escape, touch hold).
disabledbooleanfalseNever show the tooltip (the trigger still works).
classNamestringNoneAdds extra classes to the tooltip bubble.

Keyboard

KeysAction
Tab/Shift + TabFocusing the trigger shows the tooltip; leaving it hides it.
EscapeDismiss the tooltip while keeping focus on the trigger.

Accessibility

  • Tooltip adds no tab stop of its own; the trigger keeps its own. The bubble has role=“tooltip” and, while it is open, the trigger points to it with aria-describedby (added to any description it already has), so the text is announced as its description. It describes, it does not name: an icon-only trigger still needs its own aria-label.
  • Keep it to a short label. Anything interactive belongs in a Popover; essential text must not live only in a tooltip.
  • The bubble stays open while the pointer moves onto it (so it can be read while magnified) but holds no controls. On touch screens a long press (about half a second) shows it for a couple of seconds, and lifting the finger does not activate the trigger; a plain tap never shows it, so never hide the only label of a control in a tooltip. Under reduced motion it only fades.

When to use Tooltip

  • Use Tooltip to label icon-only buttons in an editor toolbar (Bold, Italic, Export) on hover and on keyboard focus, and put the shortcut, such as Ctrl+B, beside the name.
  • Use it for short supplementary hints on a form, like why a field wants a particular format, where the hint is useful but nobody is blocked without it.
  • Use TooltipProvider once near the app root so moving between neighboring triggers shows the next tip at once, and use delay to tune the 300ms default.
  • Skip it when the content is essential, long or interactive. Use Popover for controls, HoverCard for a rich preview, and plain visible text when a label must always be readable.
  • Pair it with Button using size icon, Kbd to show shortcuts inside the tip, and Avatar or Badge when a name or status needs a short explanation.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .