JGuang / JGuang UI
Components组件Radix UIRadix UI 组件

Tooltip

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

Partially translated: Chinese navigation, titles, descriptions, and common headings. The technical body is currently in English.
Loading JGuang UI example…

Installation

Command

Manual

Run the following command:

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

Add the TooltipProvider to the root of your app.

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:

npm install radix-ui

Copy and paste the following code into your project.

View complete source: components/ui/tooltip.tsx

Update the import paths to match your project setup.

Add the TooltipProvider to the root of your app.

import { TooltipProvider } from "@/components/ui/tooltip"

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

Usage

import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/components/ui/tooltip"
<Tooltip>
  <TooltipTrigger>Hover</TooltipTrigger>
  <TooltipContent>
    <p>Add to library</p>
  </TooltipContent>
</Tooltip>

Composition

Use the following composition to build a Tooltip:

Tooltip
├── TooltipTrigger
└── TooltipContent

Side

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

Loading JGuang UI example…

With Keyboard Shortcut

Loading JGuang UI example…

Disabled Button

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

Loading JGuang UI example…

RTL

To enable RTL support in JGuang UI, see the RTL configuration guide.

Loading JGuang UI example…

API Reference

See the Radix Tooltip documentation.

Source: components/radix/tooltip.mdx

Technical documentation for JGuang UI.

On this page