Tabs

Flexible navigation tool with various modes and features.

Loading...

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.

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 value from 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.

AttributeDefaultType
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
boolean

Use 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
string

The initial selected tab value when rendered. Use when you don't need to control the selected tab value.

deselectable
boolean

Whether the active tab can be deselected when clicking on it.

hideMode'display-none'
HideMode

How 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
string

The unique identifier of the machine.

ids
ElementIds

The ids of the elements in the tabs. Useful for composition.

lazyMountfalse
boolean

Whether to enable lazy mounting

loopFocustrue
boolean

Whether the keyboard navigation will loop from last tab to first, and vice versa.

navigate
(details: NavigateDetails) => void

Function to navigate to the selected tab when clicking on it. Useful if tab triggers are anchor elements.

onFocusChange
(details: FocusChangeDetails) => void

Callback to be called when the focused tab changes

onValueChange
(details: ValueChangeDetails) => void

Callback 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
IntlTranslations

Specifies the localized strings that identifies the accessibility elements and their states

unmountOnExitfalse
boolean

Whether to unmount on exit.

value
string

The controlled selected tab value

virtualFocusfalse
boolean

Whether 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).

AttributeDescription
[data-tabs-root]<uid>
[data-orientation]The orientation of the tabs
[data-focus]Present when focused
[data-activation-direction]

TabContent

Defines the <div> element.

AttributeDefaultType
value
string

The value of the tab

asChild
boolean

Use 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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDefaultType
value
string

The value of the tab

asChild
boolean

Use 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
boolean

Whether 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.

AttributeDefaultType
value
UseTabsReturn

asChild
boolean

Use 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'
HideMode

How 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+.

lazyMountfalse
boolean

Whether 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.

unmountOnExitfalse
boolean

Whether to unmount on exit.

Context

API

PropertyType
value
string | null

The current value of the tabs.

focusedValue
string | null

The value of the tab that is currently focused.

activationDirection
ActivationDirection

Where the selected tab sits relative to the previously selected one

setValue
(value: string, reason?: ValueChangeReason) => void

Sets the value of the tabs.

clearValue
VoidFunction

Clears the value of the tabs.

setIndicatorRect
(value: string) => void

Sets the indicator rect to the tab with the given value

syncTabIndex
VoidFunction

Synchronizes the tab index of the content element. Useful when rendering tabs within a select or combobox

focus
VoidFunction

Set focus on the selected tab trigger

selectNext
(fromValue?: string) => void

Selects the next enabled tab, without moving focus

selectPrevious
(fromValue?: string) => void

Selects the previous enabled tab, without moving focus

getTriggerState
(props: TriggerProps) => TriggerState

Returns the state of the trigger with the given props

getRootState
() => RootState

Returns the state of the root. The list shares it.

getContentState
(props: ContentProps) => ContentState

Returns the state of the content with the given props

getIndicatorState
() => IndicatorState

Returns the state of the indicator

Accessibility

Complies with the Tabs WAI-ARIA design pattern.

Keyboard Support

KeyDescription
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.