Components

Tooltip

A sticky note stuck next to a control, with a felt-tip arrow pointing at it. It names an icon button or adds a hint, opens on hover and keyboard focus with a shared delay, and never hides anything a person needs to be able to read.

Install

terminal
npx shadcn@latest add @wobko/tooltip

First time here? Add the registry to components.json first. How to install

Examples

Icon toolbar

The everyday use: names for icon buttons. One provider holds the delay (a calm 300 ms), and once one note is open the next opens at once as you sweep along the row. Each button still has its own aria-label.

Sides and notes

The arrow follows whichever side the note opens on (Radix flips it near the edge of the screen). Any stock makes a note: sticky pads in four colors, or a plain slip.

Delays and shortcut hints

A per-tooltip delayDuration overrides the provider's: instant for a quick label, patient for an explanation. A shortcut hint sits in the note in the mono font.

Why is it disabled?

A disabled button gets no pointer or focus events, so it cannot show a tooltip. Wrap it in a focusable span and point aria-describedby at a reason that is always in the page (the note only exists while open): keyboard, mouse and screen-reader users all learn why.

Demo

Official `tooltip-demo`: a Hover button with the note "Add to library". The note is a sticky with a felt-tip arrow, opened by hover and keyboard focus. Radix needs a `TooltipProvider` above every tooltip (shadcn's docs site supplies it at the root), so the example wraps its own.

API reference

TooltipProvider

Wrap the app or a region once. Its delays are shared by every tooltip inside, and after one has opened the next opens at once (`skipDelayDuration`). Renders no element.

PropTypeDefaultDescription
delayDurationnumber0Milliseconds of hover before a tooltip opens (upstream's default is 0; 300-700 is calmer for dense toolbars).
skipDelayDurationnumber300How long after one closes the next opens with no delay.
disableHoverableContentbooleanfalseClose as soon as the pointer leaves the trigger, without letting it travel onto the note.

TooltipContent

The sticky note: a Paper that is also the tooltip content (a CSS sheet, so it costs no SVG). Radix places it (`side`, `align`, `sideOffset`) and turns the arrow to face the trigger.

PropTypeDefaultDescription
arrowbooleantrueThe hand-drawn arrow between the note and the trigger.
stockStockName"sticky-yellow"What the note is made of: sticky-yellow, sticky-pink, sticky-blue, sticky-green, slip, index-card ...
tiltboolean | numbertrueSeeded tilt of the note (sticky stock turns up to 1.6 degrees); the text stays upright.
sideOffsetnumber1Gap between the trigger and the note, on top of the arrow's height.
collisionPaddingnumber | Partial<Record<Side, number>>8Room kept between the note and the viewport edge when it has to shift to fit (upstream's default is 0: a note at the edge of a toolbar touched the window).
seedstring | number-Pins the hand.

Accessibility

  • Radix Tooltip: the note has role=tooltip and the trigger gets `aria-describedby` while it is open; the text is announced as the trigger's description. It opens on hover and on keyboard focus, and Escape closes it.
  • Tooltips never open on a touch tap (Radix ignores touch pointers) and are not focusable themselves: never put the only copy of a label, an instruction or an error in one. An icon button still needs an `aria-label`.
  • A disabled button does not receive pointer or focus events, so it cannot show a tooltip: wrap it in a focusable element (see the example) if the reason it is disabled matters.
  • The arrow is aria-hidden decoration. Note text is ink on sticky yellow (about 12:1). With reduced motion the note appears without the zoom; in `calm` density it is a flat, untilted note.
  • Portalled content repeats the InkProvider's `data-density`, `data-motion` and `data-theme`.

Source

The files the CLI copies into your project.

Loading the source