Tooltip
A popup that displays information related to an element when it receives keyboard focus or hover.
Installation
pnpm dlx cubix@latest add tooltipAdd the Provider
Place TooltipProvider near the root of your app so tooltips share delay and portal behavior.
import { TooltipProvider } from "@/components/cubix/tooltip"
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<TooltipProvider>{children}</TooltipProvider>
</body>
</html>
)
}Usage
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/cubix/tooltip"<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
└── TooltipContentSide
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
| Prop | Type | Default | Description |
|---|---|---|---|
| delay | number | 0 | Default delay in milliseconds before any tooltip in the tree opens. |
| children | React.ReactNode | - | Tooltip trees that share this delay setting. |
Tooltip
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | Controlled open state. Omit to use uncontrolled mode. |
| defaultOpen | boolean | false | Initial open state when uncontrolled. |
| onOpenChange | (open: boolean) => void | - | Called when the open state changes. |
| delay | number | - | Delay in ms before showing. Overrides TooltipProvider when set. |
| children | React.ReactNode | - | The trigger and content elements. |
TooltipTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| render | React.ReactElement | - | Render the trigger as another element (for example a Button). |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
TooltipContent
| Prop | Type | Default | Description |
|---|---|---|---|
| side | "top" | "right" | "bottom" | "left" | "inline-start" | "inline-end" | "top" | Preferred side of the trigger to render the tooltip on. |
| sideOffset | number | 4 | Distance in pixels between the trigger and the tooltip. |
| align | "start" | "center" | "end" | "center" | Alignment of the tooltip relative to the trigger. |
| alignOffset | number | 0 | Offset in pixels along the alignment axis. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |