Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Segmented Control

ProNew

One choice out of a few, with a thumb that slides to the selected segment using a transform alone.

Installation

pnpm dlx shadcn@latest add @viewport/segmented-control

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
options*SegmentedOption[]

The choices, in order. Every segment gets the width of the widest one.

—
label*string

Accessible name for the group, e.g. "View".

—
valuestring—
defaultValuestring—
onValueChange(value: string) => void—
size"sm" | "md""md"
fullWidthboolean

Stretch to the width of the container.

false
namestring

Submits the value with a form.

—
disabledboolean—
classNamestring—

Accessibility

  • A radio group: arrow keys select, and the group has a name.
  • The thumb is in place before hydration and is mirrored in right-to-left layouts.
  • Works inside a form through `name`.
  • Respects prefers-reduced-motion.