Tooltip

A label with an optional keyboard shortcut, shown on hover and on focus.

Category
Overlays
Access
Free with an account
Source
98 lines · one file

When to use it

Use Tooltip for a short label on hover or focus, with an optional keyboard shortcut. It provides its own TooltipProvider. Never put essential information only in a tooltip.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Tooltip for this.
Install it: npx shadcn@latest add @liro/tooltip
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/tooltip.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/copy-button.tsx
import { Copy } from "lucide-react";
import { IconButton } from "@/components/ui/button";
import { Tooltip } from "@/components/ui/tooltip";

export function CopyButton({ copy }: { copy: () => void }) {
  return (
    <Tooltip label="Copy link" keys="⌘C">
      <IconButton label="Copy link" variant="ghost" onClick={copy}>
        <Copy className="h-4 w-4" />
      </IconButton>
    </Tooltip>
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
labelReact.ReactNode YesThe label. Keep it to a few words — it is a name, not documentation.
keysstring NoThe shortcut, shown dimmed after the label: "Zoom in ⌘+".
side"top" | "bottom" | "left" | "right" No–
delaynumber NoDelay before the first tooltip in a group, in ms. Used when no provider is present.
defaultOpenboolean NoStart shown, until the pointer leaves it: for docs and previews.
childrenReact.ReactElement Yes–

Dependencies

npm packages

@radix-ui/react-tooltipclsxtailwind-merge

Liro foundations, installed alongside it

liro-theme

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances

Used in a screenAll screens