suiss/ui · Component
Tabs
A set of tabs that switches between panels of related content in the same place.
Tabs is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Tabs wraps the tabs primitive of the chosen base. TabsList holds the TabsTrigger buttons, and each TabsContent panel is shown when its value matches the selected tab. An indicator slides to the active tab: a raised pill in the default variant, or an underline in the line variant.
Use Tabs to switch views within a page. For app-level navigation, use TabBar or Sidebar; for a compact single-choice control, consider a segmented ToggleGroup.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
- Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Composition
Use the following composition to build a Tabs:
Examples
Line
Set variant="line" on TabsList to underline the active tab instead of raising a pill.
Vertical
Set orientation="vertical" on Tabs to stack the tabs beside the panel. Vertical tabs use the up and down arrow keys.
With icons
Place an icon before the label inside each TabsTrigger.
Disabled tab
Set disabled on a TabsTrigger so the tab can't be selected by click or keyboard.
Set isDisabled on a TabsTrigger so the tab can't be selected by click or keyboard.
Many tabs
When there are more tabs than fit, the list scrolls horizontally and keeps the active tab in view. On small screens, a horizontal list bleeds to the edges of its scroll container.
Many tabs line
A scrolling list with variant="line" on TabsList.
Accessibility
- The list has the
tablistrole witharia-orientation; triggers aretabelements witharia-selected, and panels aretabpanelelements. - Arrow keys move focus between tabs, wrapping at the ends;
EnterorSpaceselects the focused tab. Vertical tabs use the up and down arrow keys. HomeandEndmove focus to the first and last tabs.- Disabled tabs can't be selected by click or keyboard.
API Reference
Tabs
The root that holds the selected value and orientation.
| Prop | Type | Default |
|---|---|---|
defaultValue | any | — |
value | any | — |
onValueChange | (value: any) => void | — |
orientation | "horizontal" | "vertical" | "horizontal" |
| Prop | Type | Default |
|---|---|---|
defaultValue | string | — |
value | string | — |
onValueChange | (value: string) => void | — |
orientation | "horizontal" | "vertical" | "horizontal" |
activationMode | "automatic" | "manual" | "manual" |
| Prop | Type | Default |
|---|---|---|
defaultSelectedKey | Key | — |
selectedKey | Key | null | — |
onSelectionChange | (key: Key) => void | — |
orientation | "horizontal" | "vertical" | "horizontal" |
keyboardActivation | "automatic" | "manual" | "manual" |
Also accepts the props of the primitive part it wraps.
The tabs are uncontrolled by default; set defaultValue for the first selected tab, or control them with value and onValueChange. orientation lays the tabs out in a row or a column.
The tabs are uncontrolled by default; set defaultValue for the first selected tab, or control them with value and onValueChange. orientation lays the tabs out in a row or a column. activationMode selects a tab when it gets focus (automatic), or only on Enter or Space (manual).
The tabs are uncontrolled by default; set defaultSelectedKey for the first selected tab, or control them with selectedKey and onSelectionChange. orientation lays the tabs out in a row or a column. keyboardActivation selects a tab when it gets focus (automatic), or only on Enter or Space (manual).
Each part sets a data-slot, such as tabs-list or tabs-trigger, for styling. Indicator and scroll animations are removed when reduced motion is preferred.
TabsList
The row or column of tabs, with the sliding indicator.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "line" | "default" |
Also accepts the props of the primitive part it wraps.
variant chooses a filled default list with a raised pill, or a line list with an underline; the list and indicator set data-variant. className styles the inner tabs-list-content element, not the scrolling list. The edge bleed on small screens is set through the --tabs-list-bleed-start and --tabs-list-bleed-end properties, which the list measures itself.
TabsTrigger
A tab that selects its panel.
| Prop | Type | Default |
|---|---|---|
value | string | — |
disabled | boolean | false |
| Prop | Type | Default |
|---|---|---|
id | Key | — |
isDisabled | boolean | false |
Also accepts the props of the primitive part it wraps.
value matches the value of the panel it shows. The active trigger sets data-active.
value matches the value of the panel it shows. The active trigger sets data-state="active".
id matches the id of the panel it shows. The active trigger sets data-selected.
TabsContent
The panel shown when its tab is selected.
| Prop | Type | Default |
|---|---|---|
value | string | — |
| Prop | Type | Default |
|---|---|---|
id | Key | — |
Also accepts the props of the primitive part it wraps.
Web preview
Tabs groups a TabsList of TabsTrigger buttons with matching TabsContent panels. The active tab is marked by an indicator that slides between tabs with a Reanimated layout transition.
TabsList has two variants: default, a segmented control with a raised indicator on a filled track, and line, a transparent list with a thin underline. Both work in horizontal and vertical orientation.
Installation
The CLI also adds what it builds on: Text.
- Install the following dependencies:
-
Add the pieces it builds on: Text.
-
Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/tabs.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Text.
-
Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/tabs.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Text.
-
Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/tabs.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
With icons
Tabs with an icon beside each label.
Web preview
Disabled tab
A tab set with one disabled tab.
Web preview
Line
The line variant with an underline indicator.
Web preview
Vertical
A vertical tab list next to its panels.
Web preview
Vertical line
A vertical line list with a side indicator.

With icons line
Icon tabs in the line variant.
Disabled tab line
A disabled tab in the line variant.

The React Native tab shows 2 more examples.
Accessibility
TabsListhas thetablistrole and each trigger has thetabrole.- Triggers report
selectedanddisabledin their accessibility state, so VoiceOver and TalkBack announce the current tab. - Hidden panels kept with
keepMountedare removed from the accessibility tree. - The indicator animation follows the system reduce motion setting.
API Reference
Tabs
Root that holds the active value and orientation.
Also accepts the props of React.ComponentProps<typeof TabsPrimitive.Root>.
Use defaultValue for an uncontrolled tab set, or value with onValueChange to control it. Set orientation="vertical" to stack the list beside the panels.
TabsList
Row or column of triggers with the animated indicator.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "line" | "default" |
Also accepts the props of React.ComponentProps<typeof TabsPrimitive.List>.
variant is default for a filled segmented track, or line for an underline. tabsListVariants is exported for reuse.
TabsTrigger
Pressable tab that activates its panel.
Also accepts the props of React.ComponentProps<typeof TabsPrimitive.Tab>.
Give each TabsTrigger and its TabsContent the same value. Labels are dimmed to opacity-50 when disabled.
TabsContent
Panel shown when its value is active.
Also accepts the props of React.ComponentProps<typeof TabsPrimitive.Panel>.
Inactive panels are unmounted unless you set keepMounted.
Tabs
Root that holds the active value and orientation.
| Parameter | Type | Default |
|---|---|---|
selection | Binding<Value> | - |
orientation | Axis | .horizontal |
content | () -> Content | - |
TabsListVariant
Values: .default, .line.
TabsList
Row or column of triggers with the animated indicator.
| Parameter | Type | Default |
|---|---|---|
variant | Variant: .default | .line | .default |
content | () -> Content | - |
TabsTrigger
A tab that selects its panel.
| Parameter | Type | Default |
|---|---|---|
value | Value | - |
label | () -> Label | - |
_ title | LocalizedStringKey | - |
Overloads: init(value:label:), init(_:value:).
TabsContent
Panel shown when its value is active.
| Parameter | Type | Default |
|---|---|---|
value | Value | - |
content | () -> Content | - |
TabsListVariant
Values: Default, Line.
Tabs
Root that holds the active value and orientation.
| Parameter | Type | Default |
|---|---|---|
selected | String | - |
onSelectedChange | (String) -> Unit | - |
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |
TabsList
Row or column of triggers with the animated indicator.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
variant | TabsListVariant: Default | Line | TabsListVariant.Default |
content | @Composable RowScope.() -> Unit | - |
TabsTrigger
A tab that selects its panel.
Receiver: RowScope.
| Parameter | Type | Default |
|---|---|---|
value | String | - |
text | String | - |
modifier | Modifier | Modifier |
enabled | Boolean | true |
content | @Composable RowScope.() -> Unit | - |
Overloads: TabsTrigger(value, text), TabsTrigger(value, content).
TabsContent
Panel shown when its value is active.
| Parameter | Type | Default |
|---|---|---|
value | String | - |
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |

