@@ -8,16 +8,25 @@ const Tabs = TabsPrimitive.Root
88const TabsList = React . forwardRef <
99 React . ElementRef < typeof TabsPrimitive . List > ,
1010 React . ComponentPropsWithoutRef < typeof TabsPrimitive . List >
11- > ( ( { className, ...props } , ref ) => (
12- < TabsPrimitive . List
13- ref = { ref }
14- className = { cn (
15- "inline-flex h-10 items-center justify-center rounded-md bg-card border border-border p-1 text-foreground shadow-sm dark:bg-muted dark:border-0 dark:shadow-none" ,
16- className
17- ) }
18- { ...props }
19- />
20- ) )
11+ > ( ( { className, ...props } , ref ) => {
12+ const childCount = React . Children . count ( props . children )
13+ const isSingleTab = childCount === 1
14+
15+ return (
16+ < TabsPrimitive . List
17+ ref = { ref }
18+ className = { cn (
19+ "flex h-8 sm:h-10 items-center rounded-md p-0.5 sm:p-1 text-muted-foreground bg-muted" ,
20+ "overflow-x-auto scrollbar-hide" ,
21+ "gap-0.5 sm:gap-1" ,
22+ isSingleTab ? "w-fit" : "w-full justify-center" ,
23+ "scroll-smooth" ,
24+ className
25+ ) }
26+ { ...props }
27+ />
28+ )
29+ } )
2130TabsList . displayName = TabsPrimitive . List . displayName
2231
2332const TabsTrigger = React . forwardRef <
@@ -27,7 +36,13 @@ const TabsTrigger = React.forwardRef<
2736 < TabsPrimitive . Trigger
2837 ref = { ref }
2938 className = { cn (
30- "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 text-muted-foreground hover:text-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm dark:data-[state=active]:bg-background dark:data-[state=active]:text-foreground" ,
39+ "inline-flex items-center justify-center rounded-sm transition-all data-[state=active]:shadow-sm" ,
40+ "text-sm font-medium whitespace-nowrap text-muted-foreground hover:text-foreground" ,
41+ "ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2" ,
42+ "disabled:pointer-events-none disabled:opacity-50" ,
43+ "data-[state=active]:bg-primary data-[state=active]:text-primary-foreground dark:data-[state=active]:bg-background dark:data-[state=active]:text-foreground" ,
44+ "px-1.5 py-1 text-xs sm:px-3 sm:py-1.5 sm:text-sm" ,
45+ "h-6 sm:h-8" ,
3146 className
3247 ) }
3348 { ...props }
0 commit comments