forked from MergeFi/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTabs.tsx
More file actions
44 lines (42 loc) · 1.28 KB
/
Copy pathTabs.tsx
File metadata and controls
44 lines (42 loc) · 1.28 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
43
44
"use client";
import { cn } from "@/lib/utils";
export function Tabs<T extends string>({
tabs,
active,
onChange,
}: {
tabs: { key: T; label: string; count?: number }[];
active: T;
onChange: (key: T) => void;
}) {
return (
<div className="inline-flex items-center gap-1 rounded-full border border-slate-200 bg-slate-50 p-1 dark:border-slate-800 dark:bg-slate-900">
{tabs.map((tab) => (
<button
key={tab.key}
onClick={() => onChange(tab.key)}
className={cn(
"flex items-center gap-1.5 rounded-full px-3.5 py-1.5 text-sm font-medium transition-colors",
active === tab.key
? "bg-white text-slate-900 shadow-sm dark:bg-slate-800 dark:text-white"
: "text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white",
)}
>
{tab.label}
{typeof tab.count === "number" && (
<span
className={cn(
"rounded-full px-1.5 text-xs",
active === tab.key
? "bg-slate-100 dark:bg-slate-700"
: "bg-slate-200/60 dark:bg-slate-800",
)}
>
{tab.count}
</span>
)}
</button>
))}
</div>
);
}