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

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

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. A disabled Button used as the trigger (asChild or render) stays hoverable and focusable: it is marked aria-disabled instead of disabled, in place and without a wrapper, so its layout and state do not change. A disabled control of another kind cannot emit pointer or focus events, so attach TooltipTrigger to a focusable wrapper you provide.
  • 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.
delayDurationdeprecatednumber—Compatibility alias for delay.

Also accepts Base UI Tooltip props.

Tooltip

Root that owns or receives tooltip visibility.

PropTypeDefaultDescription
openboolean—Controlled open state.
defaultOpenboolean—Initial open state in uncontrolled usage.
onOpenChangeBase UI callback—Runs when visibility changes.
delayDurationdeprecatednumber—Compatibility 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 function—Preferred 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.