Park UI

Segment Group

A form control with connected segments for selecting one option.

Installation

Usage

Shortcuts

The SegmentGroup component also provides a set of shortcuts for common use cases.

SegmentGroupItems

The SegmentGroup.Items shortcut renders a list of items based on the items prop:

This might be more concise, if you don't need to customize the items:

Examples

Sizes

Use the size prop to change the size of the segmented group.

Fitted

Use the fitted prop to make the tabs fit the width of the container.

Vertical

By default, the segmented control is horizontal. Set the orientation prop to vertical to change the orientation of the segmented group.

Icon

Use icons inside the segmented group items.

Props

Root

PropDefaultType
size'md'
'sm' | 'md'
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

defaultValue
string

The initial value of the checked radio when rendered. Use when you don't need to control the value of the radio group.

disabled
boolean

If `true`, the radio group will be disabled

form
string

The associate form of the underlying input.

id
string

The unique identifier of the machine.

ids
Partial<{ root: string label: string indicator: string item: (value: string) => string itemLabel: (value: string) => string itemControl: (value: string) => string itemHiddenInput: (value: string) => string }>

The ids of the elements in the radio. Useful for composition.

name
string

The name of the input fields in the radio (Useful for form submission).

onValueChange
(details: ValueChangeDetails) => void

Function called once a radio is checked

orientation
'horizontal' | 'vertical'

Orientation of the radio group

readOnly
boolean

Whether the checkbox is read-only

value
string

The controlled value of the radio group

Item

PropDefaultType
value*
string
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

disabled
boolean
invalid
boolean