This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ export interface TabItemProps extends PropsWithChildren {
2020 label : string
2121}
2222
23+ // for a11y, remove spaces from the tab label
24+ const removeSpaces = ( str : string ) => str . replace ( / \s / g, '' )
25+
2326export const Tabs : React . FC < TabProps > = ( {
2427 children,
2528 value,
@@ -33,16 +36,16 @@ export const Tabs: React.FC<TabProps> = ({
3336
3437 return (
3538 < BaseTabs
36- defaultValue = { tabs [ 0 ] ? tabs [ 0 ] . props . label : undefined }
39+ defaultValue = { tabs [ 0 ] ? removeSpaces ( tabs [ 0 ] . props . label ) : undefined }
3740 value = { syncKey ? get ( syncKey ) : value }
3841 onValueChange = { syncKey ? ( value ) => set ( syncKey , value ) : onValueChange }
3942 ref = { ref }
4043 >
4144 < TabsList className = "relative mx-0 mb-2 mt-auto h-12 w-full rounded-b-none bg-transparent p-0" >
4245 { tabs . map ( ( tab ) => (
4346 < TabsTrigger
44- value = { tab . props . label }
45- key = { tab . props . label }
47+ value = { removeSpaces ( tab . props . label ) }
48+ key = { removeSpaces ( tab . props . label ) }
4649 className = "group/tab relative h-12 hover:text-zinc-600 data-[state=active]:bg-transparent data-[state=active]:text-primary data-[state=active]:shadow-none dark:hover:text-zinc-200 dark:data-[state=active]:text-primary-300"
4750 >
4851 { tab . props . label }
@@ -57,5 +60,5 @@ export const Tabs: React.FC<TabProps> = ({
5760}
5861
5962export const TabItem : React . FC < TabItemProps > = ( { children, label } ) => {
60- return < TabsContent value = { label } > { children } </ TabsContent >
63+ return < TabsContent value = { removeSpaces ( label ) } > { children } </ TabsContent >
6164}
You can’t perform that action at this time.
0 commit comments