Skip to Content
Getting startedFoundationsComponentsPackagesTools

Tooltip

A short description of a control, on hover and on focus.

Examples

Playground

Placement

Hover or focus each. `top` by default; `bottom` for a trigger at the top of the viewport.

top
bottom

Content

A long tooltip wraps at the tooltip width rather than running across the page.

On focus

Tab to Copy: the tooltip shows on focus with no delay, and Escape dismisses it.

Install

npx shadcn add @hipuku/tooltip

Usage

import { Tooltip } from '@/components/haus/components/Tooltip'

<Tooltip content="Copy link">
  <IconButton icon={<LinkIcon />} label="Copy link" />
</Tooltip>

API

Tooltip also takes its element's own attributes and forwards its ref. className lands on the wrapper.

PropTypeDescription
contentrequiredstringThe text. A string rather than a node, and that is a constraint on purpose: a tooltip that can hold a link or a button is a Popover, and the moment it holds one the WCAG 1.4.13 contract below stops being satisfiable.
placement"top" | "bottom"
delaynumberMilliseconds to wait before showing on hover. Never applied to focus: a keyboard user has already committed to the element, and a delay there is just a description that arrives late. Zero by default. A delay is a judgement about a particular density of UI, and a design system guessing 400ms for everybody is a number every consumer ends up overriding.
childrenrequiredReact.ReactElement<unknown, string | React.JSXElementConstructor<any>>The element the tooltip describes. Exactly one, and it must be able to take focus: a tooltip on a <span> is invisible to every user who is not using a mouse.

Placement and timing

placement is top by default, or bottom for a control near the top of the screen. delay waits before showing on hover; it never delays focus.

A tooltip is never the only place information lives: touch has no hover. And it holds a short string only. If it needs a link, a control or more than a line, use Popover.

Accessibility

  • Shows on keyboard focus as well as on hover. The child must be focusable.
  • The child is described by the tooltip's text, which is added to its aria-describedby.
  • Escape hides it without moving focus. The pointer can move onto it, and it stays until the pointer or focus leaves, with no timeout.

On this page