CraftUI

Tooltip

A blue speech bubble with a stepped pointer, for pointer and keyboard users.

Installation

npx shadcn@latest add @runqora/craft-tooltip

Usage

import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/components/craft/tooltip";

<Tooltip>
  <TooltipTrigger>Help</TooltipTrigger>
  <TooltipContent>Opens the manual</TooltipContent>
</Tooltip>;

Examples

Placement and delay

Set where it opens with side and align. It flips by itself when there's no room. delay goes on TooltipTrigger or, to share it across a group, on TooltipProvider.

Props

TooltipContent

Prop

Type

TooltipTrigger

Prop

Type

TooltipProvider

Prop

Type

Accessibility

  • Opens on keyboard focus as well as on hover, and Escape closes it.
  • Tooltips can't be reached on touch screens, so don't put anything essential in one, and never interactive content. Use a dialog for that.
  • An icon-only trigger still needs its own aria-label. The tooltip doesn't name the button for you.

Customization

Recolor it by overriding its two tokens. The pointer follows.

<TooltipContent className="[--craft-tooltip-fg:#1e1e1f] [--craft-tooltip:#ffe866]">
  Important
</TooltipContent>

Dependencies

Source

On this page