Skip to content
Documentation navigation
Setup

Components

Tooltip

A short, non-interactive hint attached to a trigger.

Basic example

Installation

Choose the package when you want centralized updates, or copy the source through the registry when you want local ownership.

Install the package, import its global tokens once, then use this exact subpath.

# install
pnpm add @constructive-io/ui
# app/globals.css
@import '@constructive-io/ui/globals.css';
# import
import { Tooltip } from '@constructive-io/ui/tooltip';

When to use

  • Use Tooltip for a short, non-interactive hint that clarifies an otherwise understandable control.
  • Use Popover when the surface needs links, fields, or actions. Keep essential instructions and error messages visible instead of placing them only in a tooltip.

Basic usage

Wrap related tooltips in TooltipProvider, then compose TooltipTrigger and TooltipContent inside each Tooltip root. Use render for Base UI composition or asChild for compatibility, and match the visible hint to the trigger purpose.

npm source
tsx
'use client';
import { Plus } from 'lucide-react';
import { Button } from '@constructive-io/ui/button';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@constructive-io/ui/tooltip';
export function BasicTooltipDemo() {
    return (<TooltipProvider>
        <Tooltip>
          <TooltipTrigger render={<Button variant="outline" size="icon" aria-label="Create database"/>}>
            <Plus aria-hidden="true"/>
          </TooltipTrigger>
          <TooltipContent>Create database</TooltipContent>
        </Tooltip>
      </TooltipProvider>);
}

Controlled and uncontrolled open state

Tooltip normally owns its hover and focus state. Pass open and onOpenChange only when another interaction must synchronize the hint; keep pointer and keyboard access intact.

Controlled and uncontrolled open state

Examples

Placement, arrow, and delaySet delay on the provider or trigger, choose a side, and show the arrow when it improves spatial clarity.
Disabled triggerRender the trigger on a focusable wrapper when the disabled control cannot emit pointer or focus events.

Accessibility

  • Keep TooltipContent concise and non-interactive. A tooltip supplements the trigger name and cannot replace a persistent label for unfamiliar controls.
  • Make the trigger keyboard focusable. For disabled controls, attach TooltipTrigger to a wrapper that can receive pointer and focus events.
  • Base UI opens tooltips from hover or focus, closes them on Escape, and preserves the relationship through the portal chain.

API Reference

Constructive-specific behavior is listed here. Each part links to its inherited platform or primitive contract.

TooltipProvider

Coordinates open delays and behavior across related tooltips.

PropTypeDefaultDescription
delaynumber0Delay in milliseconds before opening.
delayDurationdeprecatednumberCompatibility alias for delay.

Also accepts Base UI Tooltip props.

Tooltip

Root that owns or receives tooltip visibility.

PropTypeDefaultDescription
openbooleanControlled open state.
defaultOpenbooleanInitial open state in uncontrolled usage.
onOpenChangeBase UI callbackRuns when visibility changes.
delayDurationdeprecatednumberCompatibility prop; set delay on TooltipTrigger instead.

Also accepts Base UI Tooltip props.

TooltipTrigger

Element whose hover or focus state opens the tooltip.

PropTypeDefaultDescription
delaynumber0Trigger-specific opening delay.
renderReactElement | render functionPreferred Base UI composition API.
asChildbooleanfalseCompatibility composition API.

Also accepts Base UI Tooltip props.

TooltipContent

Portal, positioner, popup, and optional arrow composition.

PropTypeDefaultDescription
side'top' | 'right' | 'bottom' | 'left''top'Preferred side of the trigger.
align'start' | 'center' | 'end''center'Alignment along the trigger edge.
sideOffsetnumber4Distance from the trigger.
showArrowbooleanfalseRenders an arrow pointing toward the trigger.

Also accepts Base UI Tooltip props.