Components
Segmented Control
Options in a bar with a sliding highlight.
<SegmentedControl label="View" options={["Day", "Week", "Month"]} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/segmented-control.jsonimport { SegmentedControl } from "@/components/segmented-control"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
A bar of options with a highlight that slides to the chosen one. Native radios underneath, so arrow keys move the choice.
import { SegmentedControl } from "@/components/segmented-control";
export function ViewPicker() {
return <SegmentedControl label="View" options={["Day", "Week", "Month"]} onChange={(v) => console.log(v)} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | Accessible name. | |
options | string[] | The choices. | |
defaultValue | string | the first | Starting choice. |
onChange | (value: string) => void | Called when the choice changes. | |
className | string | Classes for the wrapper. |
With reduced motion, the highlight jumps instead of sliding.