Components
Tooltip
A tooltip on hover and keyboard focus.
Copy to clipboard
<Tooltip content="Copy to clipboard">
<button>Copy</button>
</Tooltip>Installation
npx shadcn@latest add https://ui.zjkm.tech/r/tooltip.jsonimport { Tooltip } from "@/components/tooltip"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Text that appears on hover, after a short delay, and straight away on keyboard focus. It's linked to its trigger with aria-describedby, and Escape hides it.
import { Tooltip } from "@/components/tooltip";
export function CopyButton() {
return (
<Tooltip content="Copy to clipboard">
<button aria-label="Copy">📋</button>
</Tooltip>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
content | string | The tooltip text. | |
children | ReactElement | One focusable element, such as a button. | |
side | "top" | "bottom" | "left" | "right" | "top" | Where it appears. |
delay | number | 300 | Milliseconds before it shows on hover. |
With reduced motion, it appears without fading.