Skip to Content
zjkm-ui
Components

Tooltip

A tooltip on hover and keyboard focus.

Props
<Tooltip content="Copy to clipboard">
  <button>Copy</button>
</Tooltip>

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/tooltip.json
import { 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

PropTypeDefaultDescription
contentstringThe tooltip text.
childrenReactElementOne focusable element, such as a button.
side"top" | "bottom" | "left" | "right""top"Where it appears.
delaynumber300Milliseconds before it shows on hover.

With reduced motion, it appears without fading.

On this page