Files
upstream-shadcn-ui/apps/v4/content/docs/components/aria/tooltip.mdx
upstream-mirror 1416db152c
All checks were successful
Release / Create Version PR or Publish Stable Release (push) Has been skipped
Release / Publish Prerelease to NPM (push) Has been skipped
Monitor Registries / Monitor registry health (push) Has been skipped
snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:44:43 +05:00

105 lines
2.0 KiB
Plaintext

---
title: Tooltip
description: A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.
base: aria
component: true
links:
doc: https://react-aria.adobe.com/Tooltip
api: https://react-aria.adobe.com/Tooltip#api
---
<ComponentPreview styleName="aria-nova" name="tooltip-demo" />
## Installation
<CodeTabs>
<TabsList>
<TabsTrigger value="cli">Command</TabsTrigger>
<TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">
```bash
npx shadcn@latest add tooltip
```
</TabsContent>
<TabsContent value="manual">
<Steps className="mb-0 pt-2">
<Step>Install the following dependencies:</Step>
```bash
npm install react-aria-components
```
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource
name="tooltip"
title="components/ui/tooltip.tsx"
styleName="aria-nova"
/>
<Step>Update the import paths to match your project setup.</Step>
</Steps>
</TabsContent>
</CodeTabs>
## Usage
```tsx showLineNumbers
import { Tooltip, TooltipTrigger } from "@/components/ui/tooltip"
```
```tsx showLineNumbers
<TooltipTrigger>
<Button>Hover</Button>
<Tooltip>
<p>Add to library</p>
</Tooltip>
</TooltipTrigger>
```
## Composition
Use the following composition to build a `Tooltip`:
```text
TooltipTrigger
├── Button
└── Tooltip
```
## Placement
Use the `placement` prop to change the position of the tooltip.
<ComponentPreview styleName="aria-nova" name="tooltip-sides" />
## With Keyboard Shortcut
<ComponentPreview styleName="aria-nova" name="tooltip-keyboard" />
## Disabled Button
Show a tooltip on a disabled button by wrapping it with a span.
<ComponentPreview styleName="aria-nova" name="tooltip-disabled" />
## RTL
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
<ComponentPreview styleName="aria-nova" name="tooltip-rtl" direction="rtl" />
## API Reference
See the [React Aria Tooltip](https://react-aria.adobe.com/Tooltip#api) documentation.