apps/v4/content/docs/components/radix/tooltip.mdx
<Step>Run the following command:</Step>
npx shadcn@latest add tooltip
<Step>Add the TooltipProvider to the root of your app.</Step>
import { TooltipProvider } from "@/components/ui/tooltip"
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<TooltipProvider>{children}</TooltipProvider>
</body>
</html>
)
}
<Step>Install the following dependencies:</Step>
npm install radix-ui
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="tooltip" title="components/ui/tooltip.tsx" styleName="radix-nova" />
<Step>Update the import paths to match your project setup.</Step>
<Step>Add the TooltipProvider to the root of your app.</Step>
import { TooltipProvider } from "@/components/ui/tooltip"
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<TooltipProvider>{children}</TooltipProvider>
</body>
</html>
)
}
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip"
<Tooltip>
<TooltipTrigger>Hover</TooltipTrigger>
<TooltipContent>
<p>Add to library</p>
</TooltipContent>
</Tooltip>
Use the side prop to change the position of the tooltip.
Show a tooltip on a disabled button by wrapping it with a span.
<ComponentPreview styleName="radix-nova" name="tooltip-disabled" />To enable RTL support in shadcn/ui, see the RTL configuration guide.
<ComponentPreview styleName="radix-nova" name="tooltip-rtl" direction="rtl" />See the Radix Tooltip documentation.