Tooltip
An accessible hover and keyboard-focus tooltip that renders a dark or light bubble in a portal, with four placements that auto-flip near screen edges. It supports an arrow and an optional keyboard shortcut badge.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @reactframe in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { Tooltip } from "@/components/ui/tooltip"; export function Example() { return (<Tooltip content="Save changes" shortcut="⌘S" placement="bottom"><button type="button">Save</button></Tooltip>); }- Adding a short explanatory label to icon-only buttons or controls
- Showing a keyboard shortcut hint next to an action such as save or search
- Displaying supplementary information on hover or keyboard focus without taking up layout space
- Needing a tooltip that stays inside the viewport by flipping placement near screen edges
Examples
Basic icon button label
Wraps a button with a tooltip that appears on hover or keyboard focus.
import { Tooltip } from "@/components/ui/tooltip";export function CopyLinkButton() { return ( <Tooltip content="Copy link"> <button type="button" aria-label="Copy link" className="rounded-md border px-2 py-1 text-sm"> Copy </button> </Tooltip> );}Shortcut hint with bottom placement
Shows a keyboard shortcut badge and places the tooltip below the trigger.
import { Tooltip } from "@/components/ui/tooltip";export function SaveButton() { return ( <Tooltip content="Save changes" shortcut="⌘S" placement="bottom"> <button type="button" className="rounded-md bg-black px-3 py-1.5 text-sm text-white"> Save </button> </Tooltip> );}Light theme with a disabled state
Uses the light palette and turns the tooltip off while keeping the trigger rendered.
import { Tooltip } from "@/components/ui/tooltip";export function LockedAction({ locked }: { locked: boolean }) { return ( <Tooltip content="Available on the Pro plan" theme="light" disabled={!locked}> <button type="button" disabled={locked} className="rounded-md border px-3 py-1.5 text-sm"> Export </button> </Tooltip> );}Rich content without arrow
Passes a React node as content, hides the arrow, and widens the bubble with maxWidth.
import { Tooltip } from "@/components/ui/tooltip";export function TimestampHint() { return ( <Tooltip content={<span>Published <strong>2 minutes</strong> ago by the editorial team</span>} arrow={false} maxWidth={320} offset={8} > <time dateTime="2024-05-01T10:00:00Z" className="text-sm underline decoration-dotted"> 2m </time> </Tooltip> );}API reference
Accessibility
- The bubble has role="tooltip" and the trigger gets aria-describedby pointing to it while the tooltip is open.
- The tooltip shows on keyboard focus only when the element matches :focus-visible, so mouse clicks do not trigger it.
- Pressing Escape closes an open tooltip.
- The arrow is decorated with aria-hidden="true".
- The bubble is pointer-events-none, so it does not block interaction with the trigger.
- Icon-only triggers should still provide an accessible name such as aria-label, because the tooltip text is only referenced while open.
- Mouse down on the trigger hides the tooltip, and blur hides it too.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Tooltip" component (reactframe/tooltip) from its shadcn registry.1. Install it with: npx shadcn@latest add @reactframe/tooltip2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: content, children, placement, delay, offset, arrow, shortcut, theme, maxWidth, disabled, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Tooltip } from "@/components/ui/tooltip"; export function Example() { return (<Tooltip content="Save changes" shortcut="⌘S" placement="bottom"><button type="button">Save</button></Tooltip>); }```Files & dependencies
- registry/new-york/tooltip/tooltip.tsx