Tooltip

A popup that displays information related to an element when it receives keyboard focus or hover.

Installation

pnpm dlx cubix@latest add tooltip --base radix

Add the Provider

Place TooltipProvider near the root of your app so tooltips share delay and portal behavior.

app/layout.tsx
import { TooltipProvider } from "@/components/cubix/tooltip"

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <TooltipProvider>{children}</TooltipProvider>
      </body>
    </html>
  )
}

Usage

Import
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/components/cubix/tooltip"
Example
<Tooltip>
  <TooltipTrigger render={<Button variant="outline" />}>
    Hover
  </TooltipTrigger>
  <TooltipContent>
    <p>Add to library</p>
  </TooltipContent>
</Tooltip>

Composition

Use the following composition to build a Tooltip:

 
Tooltip
├── TooltipTrigger
└── TooltipContent

Side

Use the side prop to change the position of the tooltip.

With Keyboard Shortcut

Disabled Button

Show a tooltip on a disabled button by wrapping it with a span.

RTL

Prefer logical sides like inline-start and inline-end when mirroring layout with dir="rtl".

Delay

Wrap tooltips in TooltipProvider to share a custom open delay across a tree.

API Reference

See also the Base UI Tooltip documentation for primitive props.

TooltipProvider

PropTypeDefaultDescription
delaynumber0Default delay in milliseconds before any tooltip in the tree opens.
childrenReact.ReactNode-Tooltip trees that share this delay setting.

Tooltip

PropTypeDefaultDescription
openboolean-Controlled open state. Omit to use uncontrolled mode.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => void-Called when the open state changes.
delaynumber-Delay in ms before showing. Overrides TooltipProvider when set.
childrenReact.ReactNode-The trigger and content elements.

TooltipTrigger

PropTypeDefaultDescription
renderReact.ReactElement-Render the trigger as another element (for example a Button).
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

TooltipContent

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left" | "inline-start" | "inline-end""top"Preferred side of the trigger to render the tooltip on.
sideOffsetnumber4Distance in pixels between the trigger and the tooltip.
align"start" | "center" | "end""center"Alignment of the tooltip relative to the trigger.
alignOffsetnumber0Offset in pixels along the alignment axis.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).