Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsPlaygroundGuidesBlog
Sponsor

Segmented Control

Used to pick one choice from a linear set of options

StorybookRecipeArk

Setup

If you don't already have the snippet, run the following command to add the segmented-control snippet

npx @chakra-ui/cli snippet add segmented-control

The snippet includes a closed component composition for the SegmentGroup component.

Usage

import { SegmentedControl } from "@/components/ui/segmented-control"
<SegmentedControl items={[]} />

Examples

Sizes

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

size = xs

size = sm

size = md

size = lg

Controlled

Use the value and onValueChange props to control the selected item.

Hook Form

Here's an example of how to use the SegmentedControl with react-hook-form.

Disabled

Use the disabled prop to disable the segmented control.

Disabled Item

Use the disabled prop on the item to disable it.

Icon

Render the label as a ReactNode to render an icon.

Card

Here's an example of how to use the SegmentedControl within a Card.

Find your dream home

Props

Root

PropDefaultType
colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | 'accent'

The color palette of the component

size 'md'
'sm' | 'md' | 'lg'

The size of the component

asChild
boolean

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

For more details, read our Composition guide.
defaultValue
string

The initial value of the segment group when it is first rendered. Use when you do not need to control the state of the segment 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 value of the checked radio

Previous

Rating

Next

Select (Native)