Tabs
Flexible navigation tool with various modes and features.
Anatomy
<Tabs.Root>
<Tabs.List>
<Tabs.Trigger />
<Tabs.Indicator />
</Tabs.List>
<Tabs.Content />
</Tabs.Root>
Examples
Controlled
Pass value and update it in onValueChange.
Root Provider
Use RootProvider with the useTabs hook to access the state and methods from outside the component.
Indicator
Tabs.Indicator marks the selected tab.
Disabled
Pass disabled to a Tabs.Trigger.
Vertical
Tabs are horizontal by default. Set orientation="vertical" to stack them.
Lazy Mount
Set lazyMount to render a tab's content only when the tab is first activated. This helps when content is large.
Add unmountOnExit to unmount the content when the tab is deactivated. It re-renders the next time the tab activates.
Manual Activation
By default, a tab is selected as soon as it receives focus (automatic activation). With manual activation, a tab is selected only by pressing Enter or clicking it.
Links
Use asChild to render triggers as anchor links. This helps SEO and works with browser navigation.
Guides
Router Integration
To sync the active tab with the URL in Next.js, Remix or React Router:
- Set
valuefrom the current URL path. - Update the URL path in
onValueChange.
Here's an example with Remix:
import { Tabs } from '@ark-ui/<framework>/tabs'
import { useLocation, useNavigate, Link } from '@remix-run/react'
export default function App() {
const { pathname } = useLocation()
const navigate = useNavigate()
const lastPathFragment = pathname.substring(pathname.lastIndexOf('/') + 1)
const activeTab = lastPathFragment.length > 0 ? lastPathFragment : 'homepage'
return (
<Tabs.Root
value={activeTab}
onValueChange={({ value }) => {
navigate(`/${value === 'home' ? '' : value}`)
}}
>
<Tabs.List>
<Tabs.Trigger asChild value="home">
<Link to="">Home</Link>
</Tabs.Trigger>
<Tabs.Trigger asChild value="page-1">
<Link to="page-1">Page 1</Link>
</Tabs.Trigger>
<Tabs.Trigger asChild value="page-2">
<Link to="page-2">Page 2</Link>
</Tabs.Trigger>
</Tabs.List>
</Tabs.Root>
)
}
API Reference
Props
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
activationMode | 'automatic' | 'manual' | 'automatic'The activation mode of the tabs. Can be `manual` or `automatic` - `manual`: Tabs are activated when clicked or press `enter` key. - `automatic`: Tabs are activated when receiving focus |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
defaultValue | stringThe initial selected tab value when rendered. Use when you don't need to control the selected tab value. | |
deselectable | booleanWhether the active tab can be deselected when clicking on it. | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
id | stringThe unique identifier of the machine. | |
ids | ElementIdsThe ids of the elements in the tabs. Useful for composition. | |
lazyMount | false | booleanWhether to enable lazy mounting |
loopFocus | true | booleanWhether the keyboard navigation will loop from last tab to first, and vice versa. |
navigate | (details: NavigateDetails) => voidFunction to navigate to the selected tab when clicking on it. Useful if tab triggers are anchor elements. | |
onFocusChange | (details: FocusChangeDetails) => voidCallback to be called when the focused tab changes | |
onValueChange | (details: ValueChangeDetails) => voidCallback to be called when the selected/active tab changes | |
orientation | 'horizontal' | 'horizontal' | 'vertical'The orientation of the tabs. Can be `horizontal` or `vertical` - `horizontal`: only left and right arrow key navigation will work. - `vertical`: only up and down arrow key navigation will work. |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
translations | IntlTranslationsSpecifies the localized strings that identifies the accessibility elements and their states | |
unmountOnExit | false | booleanWhether to unmount on exit. |
value | stringThe controlled selected tab value | |
virtualFocus | false | booleanWhether the tabs use virtual focus instead of roving tabindex. When `true`, triggers receive no DOM focus — arrow keys update `focusedValue` and all triggers remain `tabIndex: -1`. Useful when tabs live inside another widget that manages focus (e.g. a combobox). |
| Attribute | Description |
|---|---|
[data-tabs-root] | <uid> |
[data-orientation] | The orientation of the tabs |
[data-focus] | Present when focused |
[data-activation-direction] |
TabContent
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | stringThe value of the tab | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<TabContentState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
TabIndicator
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
TabList
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
TabTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
value | stringThe value of the tab | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
disabled | booleanWhether the tab is disabled | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<TabTriggerState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseTabsReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
lazyMount | false | booleanWhether to enable lazy mounting |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
unmountOnExit | false | booleanWhether to unmount on exit. |
Context
API
| Property | Type |
|---|---|
value | string | nullThe current value of the tabs. |
focusedValue | string | nullThe value of the tab that is currently focused. |
activationDirection | ActivationDirectionWhere the selected tab sits relative to the previously selected one |
setValue | (value: string, reason?: ValueChangeReason) => voidSets the value of the tabs. |
clearValue | VoidFunctionClears the value of the tabs. |
setIndicatorRect | (value: string) => voidSets the indicator rect to the tab with the given value |
syncTabIndex | VoidFunctionSynchronizes the tab index of the content element. Useful when rendering tabs within a select or combobox |
focus | VoidFunctionSet focus on the selected tab trigger |
selectNext | (fromValue?: string) => voidSelects the next enabled tab, without moving focus |
selectPrevious | (fromValue?: string) => voidSelects the previous enabled tab, without moving focus |
getTriggerState | (props: TriggerProps) => TriggerStateReturns the state of the trigger with the given props |
getRootState | () => RootStateReturns the state of the root. The list shares it. |
getContentState | (props: ContentProps) => ContentStateReturns the state of the content with the given props |
getIndicatorState | () => IndicatorStateReturns the state of the indicator |
Accessibility
Complies with the Tabs WAI-ARIA design pattern.
Keyboard Support
| 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. |
ArrowRight | Moves focus to the next trigger in horizontal 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. |
Home | Moves focus to the first trigger and activates its associated content. |
End | Moves focus to the last trigger and activates its associated content. |
EnterSpace | In manual mode, when a trigger is focused, moves focus to its associated content. |