Tabs

Low-level select primitive that helps achieve accessible select menus that can be styled as needed.
Access to Fuegokit npm packages, source code repositories, and some content is limited to Appfire staff. Log in with Slack to continue.

A set of layered sections of content—known as tab panels—that are displayed one at a time.

Follows the WAI-ARIA authoring practices for tabs.

Import

import { Tabs } from "@fuegokit/react";

Additional styling guides and examples are coming soon. For now, explore the examples at Storybook.

Usage

<Tabs defaultValue="tab1" orientation="vertical">
<Tabs.List aria-label="tabs example">
<Tabs.Trigger value="tab1">One</Tabs.Trigger>
<Tabs.Trigger value="tab2">Two</Tabs.Trigger>
<Tabs.Trigger value="tab3">Three</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="tab1">Tab one content</Tabs.Content>
<Tabs.Content value="tab2">Tab two content</Tabs.Content>
<Tabs.Content value="tab3">Tab three content</Tabs.Content>

Styling

To apply styles to the Tabs primitive, use Fuegokit React's themeGet function to access Fuegokit Tokens directly.

Component API

<StyledTabs defaultValue="tab1" orientation="vertical">
<StyledTabsList aria-label="tabs example">
<StyledTabsTrigger value="tab1">One</StyledTabsTrigger>
<StyledTabsTrigger value="tab2">Two</StyledTabsTrigger>
<StyledTabsTrigger value="tab3">Three</StyledTabsTrigger>
</StyledTabsList>
<StyledTabsContent value="tab1">Tab one content</StyledTabsContent>
<StyledTabsContent value="tab2">Tab two content</StyledTabsContent>
<StyledTabsContent value="tab3">Tab three content</StyledTabsContent>

CSS

/react/src/Tabs/stories/StoryStyles.tsx

const StyledTabs = styled(Tabs)`
button,
fieldset,
input {
all: unset;
}
display: flex;
flex-direction: column;
width: 300px;

Accessibility

Follows the WAI-ARIA authoring practices for tabs.

Keyboard interactions

KeyDescription
TabWhen focus moves onto the tabs, focuses the active trigger. When a trigger is focused, moves focus to the active content.
ArrowDownMoves focus to the next trigger depending on orientation and activates its associated content.
ArrowRightMoves focus to the next trigger depending on orientation and activates its associated content.
ArrowUpMoves focus to the previous trigger depending on orientation and activates its associated content.
ArrowLeftMoves focus to the previous trigger depending on orientation and activates its associated content.
HomeMoves focus to the first trigger and activates its associated content.
EndMoves focus to the last trigger and activates its associated content.

Props

Tabs

A vertically stacked set of interactive headings that each reveal an associated section of content.
NameTypeDefaultDescription
asChild
boolean
falseChange the default rendered element for the one passed as a child, merging their props and behavior.
defaultValue
string
-The value of the tab that should be active when initially rendered. Use when you do not need to control the state of the tabs.
value
string
-The controlled value of the item to expand when type is 'single'. Must be used in conjunction with `onValueChange`.
onValueChange
(value: string) => void
-Event handler called when the value changes.
orientation
'horizontal' | 'vertical' | undefined
'horizontal'The orientation of the component.
dir
'ltr' | 'rtl'
'ltr'When `true`, prevents the user from interacting with the accordion and all its items.
activationMode
'automatic' | 'manual'
'automatic'When `automatic`, tabs are activated when receiving focus. When `manual`, tabs are activated when clicked.
Data attributes
Data attributeValues
[data-orientation]
'vertical' | 'horizontal'

Tabs.List

Contains the triggers that are aligned along the edge of the active content.
NameTypeDefaultDescription
asChild
boolean
falseChange the default rendered element for the one passed as a child, merging their props and behavior.
loop
boolean
trueWhen `true`, keyboard navigation will loop from last tab to first, and vice versa.
Data attributes
Data attributeValues
[data-orientation]
'vertical' | 'horizontal'

Tabs.Trigger

The button that activates its associated content.
NameTypeDefaultDescription
asChild
boolean
falseChange the default rendered element for the one passed as a child, merging their props and behavior.
value*
string
-A unique value that associates the trigger with a content.
disabled
boolean
falseWhen `true`, prevents the user from interacting with the tab.
Data attributes
Data attributeValues
[data-state]
'active' | 'inactive'
[data-disabled]
Present when disabled
[data-orientation]
'vertical' | 'horizontal'

Tabs.Content

Contains the content associated with each trigger.
NameTypeDefaultDescription
asChild
boolean
falseChange the default rendered element for the one passed as a child, merging their props and behavior.
value*
string
-A unique value that associates the trigger with a content.
forceMount
boolean
-Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. If used on this part, it will be inherited by DropdownMenu.Content and DropdownMenu.SubContent respectively.
Data attributes
Data attributeValues
[data-state]
'open' | 'closed'
[data-orientation]
'vertical' | 'horizontal'