npx gluestack-ui@alpha add tabsimport {
Tabs,
TabsList,
TabsTrigger,
TabsContent,
TabsTriggerText,
TabsTriggerIcon,
TabsIndicator,
} from '@/components/ui/tabs';
export default () => (
<Tabs defaultValue="tab1">
<TabsList>
<TabsTrigger value="tab1">
<TabsTriggerIcon as={IconComponent} />
<TabsTriggerText>Tab 1</TabsTriggerText>
</TabsTrigger>
<TabsTrigger value="tab2">
<TabsTriggerText>Tab 2</TabsTriggerText>
</TabsTrigger>
<TabsIndicator />
</TabsList>
<TabsContent value="tab1">
<Text>Content for Tab 1</Text>
</TabsContent>
<TabsContent value="tab2">
<Text>Content for Tab 2</Text>
</TabsContent>
</Tabs>
);
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | The controlled value of the tab to activate. Use with onValueChange. |
defaultValue | string | - | The value of the tab that should be active when initially rendered. Use when you do not need to control the state. |
onValueChange | (value: string) => void | - | Event handler called when the value changes. |
orientation | 'horizontal' | 'vertical' | 'horizontal' | The orientation of the tabs. |
activationMode | 'automatic' | 'manual' | 'automatic' | Whether tabs activate automatically on focus or manually with Enter/Space. |
disabled | boolean | false | When true, prevents the user from interacting with the tabs. |
variant | 'underlined' | 'filled' | 'enclosed' | 'underlined' | The visual style variant of the tabs. |
size | 'sm' | 'md' | 'lg' | 'md' | The size of the tabs. |
| Prop | Type | Default | Description |
|---|---|---|---|
scrollable | boolean | false | When true, enables horizontal scrolling for overflow tabs. |
snapToCenter | boolean | true | When scrollable is true, snaps the selected tab to center. |
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | A unique value that associates the trigger with a content. |
disabled | boolean | false | When true, prevents the user from interacting with the tab. |
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | A unique value that associates the content with a trigger. |
forceMount | boolean | false | Used to force mounting when more control is needed. Useful for animation. |
| Prop | Type | Default | Description |
|---|---|---|---|
as | React.ComponentType | - | The icon component to render. |
| Key | Description |
|---|---|
Tab | When focus moves onto the tabs, focuses the active trigger. When a trigger is focused, moves focus to the active content. |
ArrowDown | Moves focus to the next trigger in vertical orientation and activates its associated content. |
ArrowUp | Moves focus to the previous trigger in vertical orientation and activates its associated content. |
ArrowLeft | Moves focus to the previous trigger in horizontal orientation and activates its associated content. |
ArrowRight | Moves focus to the next trigger in horizontal orientation and activates its associated content. |
Home | Moves focus to the first trigger and activates its associated content. |
End | Moves focus to the last trigger and activates its associated content. |