Segmented control
Switch between a small set of related views.
npx shadcn@latest add @silicon-ui/segmented-controlInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/segmented-controlManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/segmented-control/segmented-control.tsx
- components/silicon-ui/segmented-control/segmented-control.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/fluid-hover.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
options* | Segment[] | — |
value* | string | — |
onValueChange* | (value: string) => void | — |
label | string | — |
onOptionIntentCalled when the pointer or focus reaches an option, before it is chosen. Use it to start loading what that option shows. | (value: string) => void | — |
size`sm` (default) or `xs`, a compact 24px control for dense UI such as an Edit/Read toggle in a toolbar. | "sm" | "xs" | "sm" |
className | string | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokens