Components
Tooltip
Built on Base UIA short label shown on hover or keyboard focus.
Installation
npx nook-ui@latest add tooltipPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Tooltip" component to this project, exactly as Nook ships it.
A short label shown on hover or keyboard focus.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add tooltip`. It writes `components/ui/tooltip.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/tooltip.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { PlusIcon } from "@/components/icons";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
export default function TooltipDefault() {
return (
<Tooltip>
<TooltipTrigger render={<Button variant="outline" size="icon" aria-label="Add to library" />}>
<PlusIcon />
</TooltipTrigger>
<TooltipContent>Add to library</TooltipContent>
</Tooltip>
);
}
```
API
- `TooltipProvider`: Optional. Shares open delays across a group.
- `delay` (`number`): Milliseconds to wait before a tooltip opens on hover.
- `Tooltip`: Owns the open state.
- `open` (`boolean`): Controlled open state.
- `onOpenChange` (`(open: boolean) => void`): Called when it opens or closes.
- `TooltipTrigger`: The element that gets the tooltip.
- `delay` (`number`): Milliseconds before it opens.
- `closeDelay` (`number`): Milliseconds before it closes.
- `TooltipContent`: The bubble.
- `side` (`"top" | "right" | "bottom" | "left"`, default "top"): Preferred side.
- `sideOffset` (`number`, default 6): Gap in pixels.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Shown on focus as well as hover, closes with Escape. Keep it to short text; never put links or buttons inside.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { PlusIcon } from "@/components/icons";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
export default function TooltipDefault() {
return (
<Tooltip>
<TooltipTrigger render={<Button variant="outline" size="icon" aria-label="Add to library" />}>
<PlusIcon />
</TooltipTrigger>
<TooltipContent>Add to library</TooltipContent>
</Tooltip>
);
}Examples
Sides
Toolbar with shortcuts
Why it is disabled
Longer help text
Retention period
Props
TooltipProvider
Optional. Shares open delays across a group.
| Prop | Type | Default | Description |
|---|---|---|---|
| delay | number | – | Milliseconds to wait before a tooltip opens on hover. |
Tooltip
Owns the open state.
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | – | Controlled open state. |
| onOpenChange | (open: boolean) => void | – | Called when it opens or closes. |
TooltipTrigger
The element that gets the tooltip.
| Prop | Type | Default | Description |
|---|---|---|---|
| delay | number | – | Milliseconds before it opens. |
| closeDelay | number | – | Milliseconds before it closes. |
TooltipContent
The bubble.
| Prop | Type | Default | Description |
|---|---|---|---|
| side | "top" | "right" | "bottom" | "left" | "top" | Preferred side. |
| sideOffset | number | 6 | Gap in pixels. |
Accessibility
Shown on focus as well as hover, closes with Escape. Keep it to short text; never put links or buttons inside.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.