Tooltip

Displays short contextual text when an element is hovered or focused.

Overview

The Tooltip component displays concise, non-essential context when users hover over or focus an element. Use it for short hints and visual labels; use inline text, popover, or toast when the information is required to complete a task.

Usage

import { Button } from "@tilt-legal/cubitt-components/button";
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@tilt-legal/cubitt-components/tooltip";
<Tooltip>
  <TooltipTrigger render={<Button variant="secondary" />}>
    Show tooltip
  </TooltipTrigger>
  <TooltipContent>Helpful context without clutter.</TooltipContent>
</Tooltip>

Examples

Default

Delay

Use delay when the trigger sits in a dense repeated control surface.

Position

Pass position props to TooltipContent when the default top placement is not the best fit.

API Reference

Tooltip

PropTypeDefaultDescription
delaynumber0Delay before this tooltip opens, in milliseconds.
openboolean-Controlled open state.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean, details: Tooltip.Root.ChangeEventDetails) => void-Callback fired when the open state changes.
onOpenChangeComplete(open: boolean) => void-Callback fired after open or close animations complete.
disabledbooleanfalsePrevents the tooltip from opening.
trackCursorAxis"none" | "x" | "y" | "both""none"Tracks the cursor on the selected axis.
disableHoverablePopupbooleanfalseCloses the tooltip when the pointer leaves the trigger.
childrenReact.ReactNode-Tooltip trigger and content parts.

TooltipTrigger

PropTypeDefaultDescription
renderReact.ReactElement-Element that receives hover and focus events, such as Button.
disabledbooleanfalsePrevents this trigger from opening the tooltip.
closeOnClickbooleantrueCloses the tooltip when the trigger is clicked.
payloadunknown-Payload passed to tooltip render-function children.
classNamestring-Additional classes for the trigger element.

TooltipContent

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left" | "inline-start" | "inline-end""top"Preferred placement relative to the trigger.
sideOffsetnumber | OffsetFunction8Distance between the trigger and tooltip.
align"start" | "center" | "end""center"Alignment relative to the trigger.
alignOffsetnumber | OffsetFunction0Offset along the alignment axis.
anchorElement | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualElement | null)-Custom element or virtual element to position against.
positionMethod"absolute" | "fixed""absolute"CSS positioning method for the tooltip positioner.
classNamestring-Additional classes for the popup surface.
childrenReact.ReactNode-Tooltip content.

TooltipProvider

PropTypeDefaultDescription
delaynumber0Shared delay applied to nested tooltips.
closeDelaynumber-Shared delay before nested tooltips close.
timeoutnumber400Window where adjacent tooltips open instantly after one was shown.
childrenReact.ReactNode-Tooltip subtree.

On this page