Back to Shark UI

Segment Group

docs/components/segment-group

latest8.7 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Segment Group

Copy Markdown

Follows the selected item.

DocsAPI

PreviewCode

Profile

Account

Security

Notifications

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/segment-group

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.

PreviewCode

Profile

Account

Security

Notifications

States#

Disabled#

Use the disabled prop to disable the entire segment group.

PreviewCode

Profile

Account

Security

Notifications

Disabled Item#

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

PreviewCode

Profile

Account

Security

Notifications

Variant#

Default#

PreviewCode

Profile

Account

Security

Notifications

Underline#

PreviewCode

Profile

Account

Security

Notifications

Orientation#

Use orientation to change the direction of the items.

Horizontal#

PreviewCode

Profile

Account

Security

Notifications

Vertical#

PreviewCode

Profile

Account

Security

Notifications

Vertical with Underline#

PreviewCode

Profile

Account

Security

Notifications

Examples#

Indicator on Hover#

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

PreviewCode

Profile

Account

Security

Notifications

Custom Indicator#

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

PreviewCode

Profile

Account

Security

Notifications

API Reference#

SegmentGroup#

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

PropTypeDefault
defaultValuestring-
valuestring-
onValueChange(details: ValueChangeDetails) => void-
orientation`"horizontal""vertical"`
variant`"default""underline"`
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.

[

Previous page

Scroll Area ](/docs/components/scroll-area)[

Next page

Select ](/docs/components/select)

On This Page

InstallationAnatomyUsageControlledStatesDisabledDisabled ItemVariantDefaultUnderlineOrientationHorizontalVerticalVertical with UnderlineExamplesIndicator on HoverCustom IndicatorAPI ReferenceSegmentGroupSegmentGroupIndicatorSegmentGroupItemSegmentGroupItemText