Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Segment Group for React Radix UI

Follows the selected item.

Framework
UI library

Installation

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

Usage

import {
  SegmentGroup,
  SegmentGroupItem,
  SegmentGroupItemText,
} from "@/components/ui/segment-group";
const SegmentGroupDemo = () => (
  <SegmentGroup className="rounded-lg" defaultValue="Profile">
    {items.map((item) => (
      <SegmentGroupItem className="px-2 py-1.5 text-sm" key={item} value={item}>
        <SegmentGroupItemText>{item}</SegmentGroupItemText>
      </SegmentGroupItem>
    ))}
  </SegmentGroup>
);

const items = ["Profile", "Account", "Security", "Notifications"];

Demos

Controlled

Custom Indicator

Disabled

Disabled Item

Indicator On Hover

Orientation Horizontal

Orientation Vertical

Variant Underline

Variant Underline Orientation Vertical

API Reference

SegmentGroup

PropType
defaultValue?string
children?ReactNode

SegmentGroupItem

PropType
valuestring
defaultValue?string
children?ReactNode
AttributeType
data-orientation?string

SegmentGroupItemText

PropType
defaultValue?string
children?ReactNode
disabled?boolean
orientation?Orientation
AttributeType

SegmentGroupIndicator

PropType
defaultValue?string
children?ReactNode
disabled?boolean
orientation?Orientation
AttributeType
CSS variableType
--heightstring
--leftstring
--topstring
--widthstring

useSegmentGroup