Captain UI

Tooltip

Waits half a second the first time, then every tooltip in the group answers instantly. Flips to whichever side has room.

npx shadcn@latest add https://captain-ui.vercel.app/r/tooltip.json

Round invoice totals half-even and add a test for the 0.005 case.

Usage

import { Tooltip, TooltipProvider } from "@/components/ui/tooltip"

<TooltipProvider>
  <Tooltip content="Attach a file" shortcut="⌘U">
    <button aria-label="Attach a file">…</button>
  </Tooltip>
</TooltipProvider>

Props

PropTypeDefaultWhat it does
contentReactNodeWhat the tooltip says. Keep it to one short line.
shortcutstringA keyboard shortcut set after the label.
side"top" | "bottom" | "left" | "right""top"Preferred side. Flips when there is no room.
offsetnumber6Gap to the trigger in px.
delaynumberOverrides the group delay for this tooltip.
TooltipProvider delaynumber500First-open delay in ms for the group.
TooltipProvider skipDelaynumber300After a tooltip closes, others open instantly for this long.

Keyboard

Tab
Show on keyboard focus
Esc
Hide

Accessibility

  • role=tooltip, wired to the trigger with aria-describedby while open.
  • Opens on keyboard focus (focus-visible only), never on a mouse click.
  • Touch never opens it: tooltips hold no information the trigger's label does not.