Segmented Control

Form-ready SegmentedControl with radiogroup semantics, a raised thumb that glides between options on a shared-layout spring, icon and/or label options, sizes, full-width layout, disabled options, arrow-key roving where selection follows focus and an optional hidden input for forms, plus a ToggleGroup of spring-pressed buttons in single or multiple mode.

Preview

Segmented Control preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/segmented-control
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

SegmentedControl

options
SegmentedControlOption[]
—
value?
string
—
defaultValue?
string
—
onValueChange?
((value: string) => void)
—
size?
"sm" | "md" | "lg"
md
fullWidth?
boolean

Stretch to the container width with equal-width segments.

false
disabled?
boolean
false
name?
string

When set, a hidden input posts the value with the surrounding form.

—
aria-label?
string
—
aria-labelledby?
string
—
className?
string
—
thumbClassName?
string
—

ToggleGroup

items
ToggleGroupItem[]
—
size?
"sm" | "md" | "lg"
—
disabled?
boolean
—
aria-label?
string
—
aria-labelledby?
string
—
className?
string
—
type
"multiple" | "single"
—
value?
string | string[]

The pressed item, or `""` when none is pressed.

—
defaultValue?
string | string[]
—
onValueChange?
((value: string) => void) | ((value: string[]) => void)
—
required?
boolean

Disallow un-pressing the active item, so one is always pressed.

—

Updated