-
Notifications
You must be signed in to change notification settings - Fork 0
/
tooltip.tsx
41 lines (35 loc) · 1.64 KB
/
tooltip.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use client";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react";
import { cn } from "./cn";
const TooltipContent = forwardRef<
ElementRef<typeof TooltipPrimitive.Content>,
ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {
// any other prop goes here
disableAnimation?: boolean;
}
>(({ className, sideOffset = 4, disableAnimation = false, ...rest }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"overflow-hidden rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs dark:bg-white",
!disableAnimation &&
"fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 animate-in data-[state=closed]:animate-out",
className,
)}
{...rest}
/>
));
const TooltipArrow = forwardRef<
ElementRef<typeof TooltipPrimitive.Arrow>,
ComponentPropsWithoutRef<typeof TooltipPrimitive.Arrow>
>(({ className, ...rest }, ref) => (
<TooltipPrimitive.Arrow ref={ref} className={cn("dark:fill-white", className)} {...rest} />
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
TooltipArrow.displayName = TooltipPrimitive.Arrow.displayName;
const TooltipProvider = TooltipPrimitive.Provider;
const Tooltip = TooltipPrimitive.Root;
const TooltipTrigger = TooltipPrimitive.Trigger;
export { Tooltip, TooltipArrow, TooltipTrigger, TooltipContent, TooltipProvider };