Skip to content

Overlays

Tooltip

tsx
import { IconButton, Tooltip } from "@cherry-design-system/react";
import { Copy } from "lucide-react";

export function CopyButton() {
  return (
    <Tooltip content="Copy to clipboard">
      <IconButton aria-label="Copy" icon={<Copy />} />
    </Tooltip>
  );
}

Tooltip shows a short, non-interactive hint when its trigger is hovered or focused. It lives in the top layer as a manual popover, anchored with CSS anchor positioning (or placed from the trigger's box in JavaScript where that is missing). For anything interactive or longer use Popover.

Examples

Placement

tsx
import { Button, Tooltip } from "@cherry-design-system/react";

export function Save() {
  return (
    <Tooltip content="Saves a draft" placement="bottom">
      <Button>Save</Button>
    </Tooltip>
  );
}

Delays

openDelay is the hover delay before showing (400ms by default) and closeDelay the delay before hiding once the pointer leaves (100ms). Right after one tooltip closes, the next opens without the delay, so sweeping across a toolbar reads label after label.

tsx
import { IconButton, Tooltip } from "@cherry-design-system/react";
import { Bold } from "lucide-react";

export function BoldButton() {
  return (
    <Tooltip content="Bold" openDelay={150} closeDelay={0}>
      <IconButton aria-label="Bold" icon={<Bold />} variant="ghost" />
    </Tooltip>
  );
}

Disabled

disabled stops the tooltip from showing while the trigger keeps working.

tsx
import { Button, Tooltip } from "@cherry-design-system/react";

export function Publish({ hint }: { hint?: string }) {
  return (
    <Tooltip content={hint} disabled={!hint}>
      <Button>Publish</Button>
    </Tooltip>
  );
}

Properties

contentReactNoderequired

The hint. Keep it short and non-interactive.

childrenReactElementrequired

The trigger: one focusable element. It receives aria-describedby.

placement"left" | "right" | "top" | "bottom"

Side of the trigger. Defaults to "top".

openDelaynumber

Hover delay before showing, in ms. Defaults to 400.

closeDelaynumber

Delay before hiding once the pointer leaves, in ms. Defaults to 100.

disabledboolean

Never show the tooltip. The trigger keeps working.

Tooltip wraps the trigger in a <span class="cherry-tooltip__trigger"> and renders the hint as a sibling <span role="tooltip">. The ref and other <span> attributes go to the hint element. Tooltip is a Client Component.

Styling

HookValues
Classcherry-tooltip
data-placementtop, bottom, left, right
States:popover-open
Partscherry-tooltip__trigger

The bubble reads --cherry-bg-inverse, --cherry-fg-inverse, --cherry-radius-md and --cherry-elevation-md.

Accessibility

The tooltip has role="tooltip" and is linked to its trigger with aria-describedby. It shows on hover and keyboard focus, Escape hides it, and the pointer can move onto it without closing it. Never put essential information or controls inside, and give the trigger its own accessible name: the tooltip describes it, it does not name it.