Skip to content
shadcn.io is not affiliated with official shadcn/ui

Shadcn Segment Group for React and Tailwind

Follows the selected item.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/segment-group.json

Anatomy

SegmentGroup
└── SegmentGroupItem
    └── SegmentGroupItemText

Usage

import {
  SegmentGroup,
  SegmentGroupIndicator,
  SegmentGroupItem,
  SegmentGroupItemText,
} from "@/components/ui/segment-group";
<SegmentGroup>
  <SegmentGroupIndicator />
  <SegmentGroupItem value="profile">
    <SegmentGroupItemText />
  </SegmentGroupItem>
  <SegmentGroupItem value="account">
    <SegmentGroupItemText />
  </SegmentGroupItem>
</SegmentGroup>

Controlled

Control the selected value programmatically with value and onValueChange props.

States

Disabled

Use the disabled prop to disable the entire segment group.

Disabled Item

Use the disabled prop on individual items to disable specific options.

Variant

Default

Underline

Orientation

Use orientation to change the direction of the items.

Horizontal

Vertical

Vertical with Underline

Examples

Indicator on Hover

The indicator follows the mouse and returns to the selected item when not hovering.

Custom Indicator

Use *:data-[slot=segment-group-indicator]:bg-* classes to change the color of the indicator.

API Reference

SegmentGroup

Root component. Manages segmented control state (single or multi-select).

PropTypeDefault
defaultValuestring-
valuestring-
onValueChange(details: ValueChangeDetails) => void-
orientation"horizontal" | "vertical""horizontal"
variant"default" | "underline""default"
disabledboolean-
classNamestring-
asChildboolean-

SegmentGroupIndicator

Visual indicator that moves to the selected segment(s).

PropTypeDefault
asChildboolean-
classNamestring-

SegmentGroupItem

Single segment option. Use value for selection.

PropTypeDefault
valuestring-
disabledboolean-
classNamestring-
asChildboolean-

SegmentGroupItemText

Text label for a segment. Often wraps icon + text.

PropTypeDefault
classNamestring-
asChildboolean-

For a complete list of props, see the Ark UI documentation.