Skip to content
Source
Sign inSign up
TanStack/cli
Open History to see the last commit

tabs.tsx

64 lines1.9 KB

1import * as React from 'react'
2import * as TabsPrimitive from '@radix-ui/react-tabs'
3​
4import { cn } from '../../lib/utils'
5​
6function Tabs({
7 className,
8 ...props
9}: React.ComponentProps<typeof TabsPrimitive.Root>) {
10 return (
11 <TabsPrimitive.Root
12 data-slot="tabs"
13 className={cn('flex flex-col gap-2', className)}
14 {...props}
15 />
16 )
18​
19function TabsList({
20 className,
21 ...props
22}: React.ComponentProps<typeof TabsPrimitive.List>) {
23 return (
24 <TabsPrimitive.List
25 data-slot="tabs-list"
26 className={cn(
27 'bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]',
28 className,
29 )}
30 {...props}
31 />
32 )
34​
35function TabsTrigger({
36 className,
37 ...props
38}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
39 return (
40 <TabsPrimitive.Trigger
41 data-slot="tabs-trigger"
42 className={cn(
43 "data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
44 className,
45 )}
46 {...props}
47 />
48 )
50​
51function TabsContent({
52 className,
53 ...props
54}: React.ComponentProps<typeof TabsPrimitive.Content>) {
55 return (
56 <TabsPrimitive.Content
57 data-slot="tabs-content"
58 className={cn('flex-1 outline-none', className)}
59 {...props}
60 />
61 )
63​
64export { Tabs, TabsList, TabsTrigger, TabsContent }