SegmentedControl
Pill-shaped switcher between 2–5 views or modes.
Code
import * as React from 'react';
import { SegmentedControl } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
maxWidth: 360,
}}
>
<SegmentedControl
options={['Day', 'Week', 'Month', 'Year']}
defaultValue="Week"
label="Range"
/>
</div>
);
}With icons
import { SegmentedControl } from '@fruit-labs/design';
export default function Example() {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, alignItems: 'center' }}>
<SegmentedControl label="View" options={[{ value: 'grid', label: 'Grid', icon: 'grid' }, { value: 'chart', label: 'Chart', icon: 'chart' }]} />
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { SegmentedControl } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/segmented-control.jsonGuidelines
- Switches views of the same content (Day/Week/Month, Grid/List). For navigation between pages use Tabs.
Props
| Prop | Type | Required |
|---|---|---|
options | Array<string | { value: string; label: React.ReactNode; icon?: string }> | Yes |
value | string | No |
defaultValue | string | No |
onChange | (value: string) => void | No |
label | string | No |
className | string | No |
style | React.CSSProperties | No |