# Tooltip · JGuang UI

> A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/base/tooltip
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `tooltip-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/tooltip


## Installation


  

**Command**


  

**Manual**


### Run the following command:


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Add the `TooltipProvider` to the root of your app.


```tsx title="app/layout.tsx" showLineNumbers {1,7}
import { TooltipProvider } from "@/components/ui/tooltip"

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <TooltipProvider>{children}</TooltipProvider>
      </body>
    </html>
  )
}
```


### Install the following dependencies:


```bash
npm install @base-ui/react
```


### Copy and paste the following code into your project.


[View complete source: components/ui/tooltip.tsx](/r/jguang-ui/base/tooltip.json)


### Update the import paths to match your project setup.


### Add the `TooltipProvider` to the root of your app.


```tsx title="app/layout.tsx" showLineNumbers {1,7}
import { TooltipProvider } from "@/components/ui/tooltip"

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <TooltipProvider>{children}</TooltipProvider>
      </body>
    </html>
  )
}
```


## Usage

```tsx showLineNumbers
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/components/ui/tooltip"
```

```tsx showLineNumbers
<Tooltip>
  <TooltipTrigger>Hover</TooltipTrigger>
  <TooltipContent>
    <p>Add to library</p>
  </TooltipContent>
</Tooltip>
```

## Composition

Use the following composition to build a `Tooltip`:

```text
Tooltip
├── TooltipTrigger
└── TooltipContent
```

## Side

Use the `side` prop to change the position of the tooltip.


> Example `tooltip-sides`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/tooltip


## With Keyboard Shortcut


> Example `tooltip-keyboard`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/tooltip


## Disabled Button

Show a tooltip on a disabled button by wrapping it with a span.


> Example `tooltip-disabled`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/tooltip


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> Example `tooltip-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/tooltip


## API Reference

See the [Base UI Tooltip](https://base-ui.com/react/components/tooltip#api-reference) documentation.

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
