Skip to Content
NarakUI

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 Radix tablist without matching Content panels tells assistive tech to expect tabpanels that do not exist; the toggle group keeps button/aria-pressed semantics 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-tabs

Add "@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

PropTypeDefaultDescription
valuestring—Value of the active tab when controlled
defaultValuestring—Active tab on first render when uncontrolled
onValueChange(value: string) => void—Called when the active tab changes

SegmentedToggleGroup.Root Properties

PropTypeDefaultDescription
valuestringRequiredValue of the selected item
onValueChange(value: string) => void—Called with the item value when the user selects a different button item
aria-labelstring—Accessible name for the group
classNamestring—Additional classes for the group

SegmentedToggleGroup.Item Properties

PropTypeDefaultDescription
valuestringRequiredValue that selects this item
childrenReactNodeRequiredItem label
hrefstring—Renders the item as a link to this URL
prefetchboolean | 'auto' | null—Route prefetch for link items, passed to Next.js Link
classNamestring—Additional classes for the item