Segmented Tabs
Pill-styled tabs where the active trigger fills with a control surface instead of showing an underline.
Built on the same Radix primitives as Tabs, so it works as a full tab set or as a standalone controlled view switcher when the panel content is rendered elsewhere.
Basic
A full segmented tab set with content panels.
Topics plotted by visibility and sentiment, so the gaps stand out.
Controlled (list only)
Use value + onValueChange and omit Content when the active view's content is rendered elsewhere, e.g. in a section body separate from the toolbar.
For a toolbar switcher whose content lives outside the control, prefer
SegmentedToggleGroup(below). A Radixtablistwithout matchingContentpanels tells assistive tech to expecttabpanels that do not exist; the toggle group keeps button/aria-pressedsemantics instead.
42.6%
Toggle group (button semantics)
SegmentedToggleGroup has the same pill look but renders a role="group" of toggle buttons with aria-pressed instead of a Radix tablist. Use it for toolbar switchers that swap surrounding content rather than Radix tab panels. Pass an aria-label on the Root to name the group.
Pass href to an item when the selected view lives in the URL. The item renders as a link, so it can open in a new tab. Following the link selects it, so onValueChange does not fire and can be omitted when every item is a link.
Showing topics as a matrix.
Installation
pnpm dlx shadcn@latest add @narakui/segmented-tabsAdd "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/segmented-tabs.json.
Usage
import {
SegmentedTabs,
SegmentedToggleGroup,
} from '@/components/ui/segmented-tabs';
<SegmentedTabs.Root defaultValue="matrix">
<SegmentedTabs.List>
<SegmentedTabs.Trigger value="matrix">Matrix</SegmentedTabs.Trigger>
<SegmentedTabs.Trigger value="table">Table</SegmentedTabs.Trigger>
</SegmentedTabs.List>
<SegmentedTabs.Content value="matrix">Matrix view</SegmentedTabs.Content>
<SegmentedTabs.Content value="table">Table view</SegmentedTabs.Content>
</SegmentedTabs.Root>;SegmentedTabs.Root Properties
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Value of the active tab when controlled |
defaultValue | string | — | Active tab on first render when uncontrolled |
onValueChange | (value: string) => void | — | Called when the active tab changes |
SegmentedToggleGroup.Root Properties
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | Required | Value of the selected item |
onValueChange | (value: string) => void | — | Called with the item value when the user selects a different button item |
aria-label | string | — | Accessible name for the group |
className | string | — | Additional classes for the group |
SegmentedToggleGroup.Item Properties
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | Required | Value that selects this item |
children | ReactNode | Required | Item label |
href | string | — | Renders the item as a link to this URL |
prefetch | boolean | 'auto' | null | — | Route prefetch for link items, passed to Next.js Link |
className | string | — | Additional classes for the item |