8
8
TabPanels
9
9
} from '@headlessui/react'
10
10
import type {
11
+ TabProps as HeadlessTabProps ,
11
12
TabGroupProps ,
12
13
TabListProps ,
13
14
TabPanelProps
@@ -32,16 +33,18 @@ export const Tabs: FC<
32
33
items : ( TabItem | TabObjectItem ) [ ]
33
34
children : ReactNode
34
35
storageKey ?: string
35
- } & Pick < TabGroupProps , 'defaultIndex' | 'selectedIndex' | 'onChange' > &
36
- Pick < TabListProps , 'className' >
36
+ className ?: TabListProps [ 'className' ]
37
+ tabClassName ?: HeadlessTabProps [ 'className' ]
38
+ } & Pick < TabGroupProps , 'defaultIndex' | 'selectedIndex' | 'onChange' >
37
39
> = ( {
38
40
items,
39
41
children,
40
42
storageKey,
41
43
defaultIndex = 0 ,
42
44
selectedIndex : _selectedIndex ,
43
45
onChange,
44
- className
46
+ className,
47
+ tabClassName
45
48
} ) => {
46
49
const [ selectedIndex , setSelectedIndex ] = useState ( defaultIndex )
47
50
@@ -109,8 +112,9 @@ export const Tabs: FC<
109
112
< HeadlessTab
110
113
key = { index }
111
114
disabled = { isTabObjectItem ( item ) && item . disabled }
112
- className = { ( { selected, disabled, hover, focus } ) =>
113
- cn (
115
+ className = { args => {
116
+ const { selected, disabled, hover, focus } = args
117
+ return cn (
114
118
focus && 'nextra-focusable _ring-inset' ,
115
119
selected && '_outline-none' ,
116
120
'_whitespace-nowrap' ,
@@ -127,9 +131,12 @@ export const Tabs: FC<
127
131
? '_text-gray-400 dark:_text-neutral-600 _pointer-events-none'
128
132
: hover
129
133
? '_text-black dark:_text-white'
130
- : '_text-gray-600 dark:_text-gray-200'
134
+ : '_text-gray-600 dark:_text-gray-200' ,
135
+ typeof tabClassName === 'function'
136
+ ? tabClassName ( args )
137
+ : tabClassName
131
138
)
132
- }
139
+ } }
133
140
>
134
141
{ isTabObjectItem ( item ) ? item . label : item }
135
142
</ HeadlessTab >
0 commit comments