A short hint on hover or focus, on any side. Rendered above everything, including dialogs.
Used for
- Icon button label
- Shortcut hint
- Truncated name
- Disabled reason
Examples
Installation
npx knowns-ui@latest add tooltip popoverFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Tooltip, Popover from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/tooltip
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add tooltip popover
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/popover.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/tooltip, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "tooltip" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- content
ReactNode- Tooltip text. Read as the trigger's description (aria-describedby on the child).
- description
ReactNode- Second, muted line.
- side / align
"top"|"bottom"|"left"|"right" / "start"|"center"|"end"- Default
"top" / "center" - Preferred placement. Flips to the opposite side when there is no room and stays 8px inside the viewport.
- delay / closeDelay
number- Default
300 / 80 - Hover delays in ms. Keyboard focus shows it at once; Escape hides it.
- TooltipGroup
delay?: number, closeDelay?: number- Default
- / 140 - Wrap a row of triggers. They share one tooltip: the first opens after its delay, moving to the next glides the same tooltip over and morphs its size to the new text, with no delay. Jumps instead of gliding under reduced motion.
- disabled
boolean- Default
false - Never show. It also hides itself while the trigger's popup is open (aria-expanded).
- Popover side / align
"top"|"bottom" / "start"|"center"|"end"- Default
"bottom" / "start" - Same floating engine. Focus moves into the panel; Tab continues after the trigger.
| Prop | Type | Default | Description |
|---|---|---|---|
| content | ReactNode | - | Tooltip text. Read as the trigger's description (aria-describedby on the child). |
| description | ReactNode | - | Second, muted line. |
| side / align | "top" | "bottom" | "left" | "right" / "start" | "center" | "end" | "top" / "center" | Preferred placement. Flips to the opposite side when there is no room and stays 8px inside the viewport. |
| delay / closeDelay | number | 300 / 80 | Hover delays in ms. Keyboard focus shows it at once; Escape hides it. |
| TooltipGroup | delay?: number, closeDelay?: number | - / 140 | Wrap a row of triggers. They share one tooltip: the first opens after its delay, moving to the next glides the same tooltip over and morphs its size to the new text, with no delay. Jumps instead of gliding under reduced motion. |
| disabled | boolean | false | Never show. It also hides itself while the trigger's popup is open (aria-expanded). |
| Popover side / align | "top" | "bottom" / "start" | "center" | "end" | "bottom" / "start" | Same floating engine. Focus moves into the panel; Tab continues after the trigger. |
What it handles
- 01Wraps one child, usually a button or link, and shows content on hover after delay (about a third of a second) or on keyboard focus at once.
- 02Adds an optional muted description line under the hint, and describes the child itself through aria-describedby while it shows.
- 03Opens in a portal with side and align, flips when there is no room, and keeps pointer events off the bubble.
- 04Hides on Escape, on pointer down and on blur, and hides itself while the trigger has aria-expanded true, so it never covers an open menu.
- 05Warms up: a second tooltip opened within a moment of the last close appears with no fade, which suits a sweep along a toolbar.
- 06Skips touch pointers, and disabled keeps the trigger working while never showing the hint.
States
- First render
- Nothing. The bubble is not mounted until it opens
- none
- Hover or focus
- The bubble fades in after the delay
- 120ms, opacity only
- Next tooltip in a sweep
- It appears with no fade at all
- none
- Pointer leaves
- After a short close delay the bubble fades out a little quicker
- 120ms, opacity only
- Reduced motion
- It appears and unmounts at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The bubble is not mounted until it opens | none |
| Hover or focus | The bubble fades in after the delay | 120ms, opacity only |
| Next tooltip in a sweep | It appears with no fade at all | none |
| Pointer leaves | After a short close delay the bubble fades out a little quicker | 120ms, opacity only |
| Reduced motion | It appears and unmounts at once | 0ms |
Works with
When to use
When to use
- A short hint for an icon button or a truncated label, on hover and focus.
When not to use
- Content with links or controls: use Popover.
- Information the user needs on touch screens: there is no hover there.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Tooltip to my app and wire it to my own data.
- I need a short hint for an icon button or a truncated label, on hover and focus. Set that up with the Knowns UI Tooltip.
- Which Tooltip props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "tooltip" }) and search_docs({ query: "tooltip" }).