Skip to content

Tabs

The Tabs component organizes content into multiple panels, each associated with a tab trigger. It comes in two modes: regular tabs that show and hide panels, and navigation tabs (Tabs.NavRoot) that integrate with your router.

It is composed from Tabs.Root, Tabs.NavRoot, Tabs.List, Tabs.Trigger, and Tabs.Content, so you assemble exactly the structure you need.

Variations

Variants

Apply a visual style with the variant prop on Tabs.List.

With icons

Tab triggers can include icons to enhance visual recognition and improve user experience.

With logos

Tab triggers can display logos for brand-specific navigation or integration tabs.

With counters

Tab triggers can display counter badges to show quantities or notifications.

Complex children

When icons, logos, and counters aren’t sufficient, you can use custom children for more complex tab triggers.

The Tabs.NavRoot variant integrates with your router to create navigation-based tabs that update based on the current route.

Controlled tabs

Both Tabs.Root and Tabs.NavRoot can be controlled by passing value and onValueChange props.

Orientation

The Tabs component supports both horizontal (default) and vertical orientations via the orientation prop on Tabs.Root. This affects both the visual layout and keyboard navigation behavior.

Scrollable tabs

When you have many tabs that overflow the container, the component automatically enables horizontal scrolling with fade indicators on both ends. The active tab will automatically scroll into view on mount and when changed.

Custom active class

You can customize the active tab styling using the activeClassName prop on Tabs.List.

Installation

import { Tabs } from "@harnessio/ui/components";
<Tabs.Root defaultValue="general">
<Tabs.List>
<Tabs.Trigger value="general">General</Tabs.Trigger>
<Tabs.Trigger value="security">Security</Tabs.Trigger>
<Tabs.Trigger value="advanced">Advanced</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="general">{/* General settings */}</Tabs.Content>
<Tabs.Content value="security">{/* Security settings */}</Tabs.Content>
<Tabs.Content value="advanced">{/* Advanced settings */}</Tabs.Content>
</Tabs.Root>;