Tooltip
A lightweight popup that provides helpful information on hover or focus. Built on Radix UI with customizable positions, sizes, and animations.
Installation
Add Tooltip to your project with the CK-UI CLI. It copies the source into your project, so the code is yours to change.
- Adds
Tooltip.tsxThemeScope.tsxto your CK-UI folder (src/components/ck-ui by default)- Installs
@radix-ui/react-slot@radix-ui/react-tooltipif your project does not have them yet
First time with CK-UI in this project? Run npx ck-ui-cli@latest init once before adding components. The installation guide explains what it sets up.
Manual installationInstall the packages and copy the files yourself.
Install the following dependencies
Run these commands in your terminal to install the required packages
Add the ThemeScope component
Tooltip imports ./ThemeScope, so add this file next to it
Create or update your Tooltip component
Copy this code to create your Tooltip component
Test Your Component
- 1. Add the component to a test page
- 2. Check all props and variants work as expected
- 3. Verify responsive behavior
- 4. Test with different content/data
- 5. Ensure accessibility features work correctly
Positions
Tooltips can be positioned in different directions around the trigger element.
Sizes
Tooltips come in different sizes to accommodate various content needs.
Animations
Various animations can be applied to tooltips when they appear and disappear.
API Reference
The Tooltip component is built on top of the Radix UI Tooltip primitive and extends its functionality with additional styling options and features.
Tooltip.Provider
Provider component that shares tooltip settings across all tooltips in its scope. Wrap a group of tooltips (or the whole app) in one Provider so moving between them skips the open delay. A Tooltip.Root outside any Provider creates its own.
See Radix UI docs for base props.
| Prop | Type | Default | Description |
|---|---|---|---|
delayDuration | "number" | "200" | Default delay duration for all tooltips (ms) |
skipDelayDuration | "number" | "300" | Skip delay when quickly moving between tooltips (ms) |
disableHoverableContent | "boolean" | "false" | Prevents hovering content from keeping tooltip open |
Tooltip.Root
The main container component that manages the tooltip state.
See Radix UI docs for base props. Only extended props shown below.
| Prop | Type | Default | Description |
|---|---|---|---|
delayDuration | "number" | "200" | Delay in ms before showing the tooltip. Inside a Tooltip.Provider it defaults to the Provider's value. |
skipDelayDuration | "number" | "300" | Only for a Root used without Tooltip.Provider (it then creates its own). Inside a Provider, set it on the Provider instead. |
Tooltip.Trigger
The element that triggers the tooltip to appear when hovered or focused. It must be focusable (use asChild with a button or link) so keyboard users get the tooltip too.
See Radix UI docs for base props.
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | "boolean" | "false" | Merges props onto child element |
Tooltip.Content
The content displayed when the tooltip is visible.
See Radix UI docs for base props. Only extended props shown below.
| Prop | Type | Default | Description |
|---|---|---|---|
showArrow | "boolean" | "true" | Whether to show the arrow indicator |
unstyled | "boolean" | "false" | Removes the default surface, padding and typography |
animation | "fade""scale""slide" | "slide" | Animation style when opening/closing |
size | "sm""md""lg" | "md" | Size variant of the tooltip. small / medium / large are deprecated aliases. |
position | "top-left""top-center""top-right""bottom-left""bottom-center""bottom-right""left""right" | "top-center" | Position relative to the trigger |
Used in these blocks
Block families with at least one block built on this component. Each page previews its blocks and lists the components and packages they use.