Add to library
Component
tooltip-demo
not found in registry.
import { Button } from "@/components/ui/button"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip"
export default function TooltipDemo() {
return (
<Tooltip>
<TooltipTrigger asChild>
<Button variant="outline">Hover</Button>
</TooltipTrigger>
<TooltipContent>
<p>Add to library</p>
</TooltipContent>
</Tooltip>
)
}
Not found
Installation
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { Tooltip as TooltipPrimitive } from "@ark-ui/react/tooltip"
import { cn } from "@/lib/utils"
const Tooltip = TooltipPrimitive.Root
const TooltipTrigger = TooltipPrimitive.Trigger
const TooltipPositioner = TooltipPrimitive.Positioner
const TooltipContext = TooltipPrimitive.Context
const TooltipArrow = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Arrow>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Arrow>
>(({ className, ...props }, ref) => (
<TooltipPrimitive.Arrow>
<TooltipPrimitive.ArrowTip
ref={ref}
className={cn("border-t-[1px] border-l-[1px]", className)}
{...props}
/>
</TooltipPrimitive.Arrow>
))
TooltipArrow.displayName = "TooltipPrimitiveArrow"
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentProps<typeof TooltipPrimitive.Content>
>(({ className, ...props }, ref) => (
<TooltipPositioner>
<TooltipPrimitive.Content
ref={ref}
className={cn(
"fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 z-50 animate-in overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-popover-foreground text-sm shadow-md data-[state=closed]:animate-out",
className
)}
{...props}
/>
</TooltipPositioner>
))
export {
Tooltip,
TooltipArrow,
TooltipContent,
TooltipContext,
TooltipPositioner,
TooltipTrigger,
}
Not Found
Update the import paths to match your project setup.
Usage
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip"
<Tooltip>
<TooltipTrigger>Hover</TooltipTrigger>
<TooltipContent>
<p>Add to library</p>
</TooltipContent>
</Tooltip>