# Segmented Control (Andromeda Legacy)

Segmented Control is a component of the free, MIT-licensed Andromeda Legacy design system from AI Canvas (https://aicanvas.me). Index of every system, component and install setup: https://aicanvas.me/llms.txt

Row of icon-or-label buttons that share a single border. The active background slides between segments on selection. Sized sm/md/lg to match the row baseline.

- Design system: [Andromeda Legacy](https://aicanvas.me/design-systems/andromeda.md)
- License: MIT
- Install slug: `andromeda-segmented-control`
- Page: https://aicanvas.me/design-systems/andromeda/segmented-control

## Install

```bash
npx shadcn@latest add @aicanvas/andromeda-segmented-control
```

Needs a free AI Canvas account; signed out, the command writes a placeholder (an `AccountRequired` notice) instead.

Every Andromeda Legacy component at once: `npx shadcn@latest add @aicanvas/andromeda`.

Token setup: the Install section of https://aicanvas.me/llms.txt.

## Use it

It installs to `components/aicanvas/andromeda/components/SegmentedControl.tsx` (under `src/` if your project has one). With the usual `@/` alias:

```tsx
import { SegmentedControl } from '@/components/aicanvas/andromeda/components/SegmentedControl'
```

## Example

```tsx
import { useState } from 'react'
import { SegmentedControl } from '@/components/aicanvas/andromeda/components/SegmentedControl'

const [period, setPeriod] = useState('week');

<SegmentedControl
  value={period}
  onChange={setPeriod}
  options={[{ value: 'week', label: 'Week' }, { value: 'month', label: 'Month' }]}
/>
```

## Parts

Segmented Control is built from `SegmentOption` and `SegmentedControl`. Each part has its own props table below.

## Variants

- `size` on `SegmentedControl`: sm, md or lg (default 'md')

## Props

### SegmentOption

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` |  | Unique value that identifies this segment. |
| `label?` | `string` |  | Text shown on the segment. |
| `icon?` | `React.ComponentType<IconProps>` |  | Icon component rendered in the segment, optionally alongside its label. |
| `ariaLabel?` | `string` |  | Accessible name for the segment, falling back to label when omitted. |

### SegmentedControl

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` |  | Value of the currently selected segment. |
| `onChange` | `(next: string) => void` |  | Handler called with the value of the newly selected segment. |
| `options` | `SegmentOption[]` |  | Segments to render, in display order. |
| `size?` | `'sm'\|'md'\|'lg'` | `'md'` | Height and icon-size preset for the control. |
| `layoutGroupId?` | `string` |  | Override the auto-generated per-instance id only when you explicitly want two SegmentedControls to share their indicator (animating across both as one unit). The default `useId()` value scopes the indicator to a single control, which is what you want 99% of the time, without it, switching selections in one control makes the indicator fly between controls. |
| `className?` | `string` |  | Extra classes merged onto the root element. |
| `style?` | `React.CSSProperties` |  | Inline styles merged onto the root element. |

## More Andromeda Legacy components

- [Slider](https://aicanvas.me/design-systems/andromeda/slider.md)
- [Spinner](https://aicanvas.me/design-systems/andromeda/spinner.md)
- [Stat Tile](https://aicanvas.me/design-systems/andromeda/stat-tile.md)
- [Tag](https://aicanvas.me/design-systems/andromeda/tag.md)
- [Textarea](https://aicanvas.me/design-systems/andromeda/textarea.md)
