forked from valkey-io/valkey-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-tooltip.tsx
More file actions
42 lines (40 loc) · 1.12 KB
/
custom-tooltip.tsx
File metadata and controls
42 lines (40 loc) · 1.12 KB
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
42
import React from "react"
import {
Tooltip,
TooltipContent,
TooltipTrigger
} from "@radix-ui/react-tooltip"
interface CustomTooltipProps {
children: React.ReactNode;
content?: string;
description?: string;
unit?: string;
}
export function CustomTooltip({ children, content, description, unit }: CustomTooltipProps) {
return (
<Tooltip delayDuration={200}>
<TooltipTrigger asChild>{children}</TooltipTrigger>
{content &&
<TooltipContent
align="center"
className={"bg-tw-primary text-white px-2 py-1 mt-1 rounded text-xs font-light z-10"}
side="bottom"
>
<p>{content}</p>
</TooltipContent>
}
{description &&
<TooltipContent
align="center"
className={"bg-tw-primary text-white px-2 py-1 mt-1 rounded text-xs font-light z-10 w-1/2"}
side="right"
>
<p>{description}</p>
{unit && (
<p className="bg-white/20 rounded-full px-1 py-0.5 text-xs mt-1 font-medium text-white inline-block w-fit">{unit}</p>
)}
</TooltipContent>
}
</Tooltip>
)
}