# Segmented

Source: https://ecosphere.dev/docs/forms/segmented (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

A filter over one dimension where the options are few, exclusive, and worth seeing at once.

`import { EcoSegmented } from "vue-ecosphere"`

## Stages, with the count inside each option

Vue (vue-ecosphere):

```vue
<EcoSegmented v-model="stage" label="Stage" :options="[
  { label: 'All', value: 'all', count: 268 },
  { label: 'Received', value: 'received', count: 78 },
  …
]" />
```

React (react-ecosphere):

```tsx
const [stage, setStage] = useState<string | null>("all");

<EcoSegmented value={stage} onChange={setStage} label="Stage" options={[
  { label: "All", value: "all", count: 268 },
  { label: "Received", value: "received", count: 78 },
  …
]} />
```

## seg--tight, with the three register marks

Vue (vue-ecosphere):

```vue
<EcoSegmented v-model="mark" label="Mark" tight :options="[
  { label: 'Present', value: 'present', mark: 'p' },
  { label: 'Absent', value: 'absent', mark: 'a' },
  { label: 'Late', value: 'late', mark: 'l' },
]" />
```

React (react-ecosphere):

```tsx
const [mark, setMark] = useState<string | null>("present");

<EcoSegmented value={mark} onChange={setMark} label="Mark" tight options={[
  { label: "Present", value: "present", mark: "p" },
  { label: "Absent", value: "absent", mark: "a" },
  { label: "Late", value: "late", mark: "l" },
]} />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model` | `string \| number \| null` | null | The chosen value — options are mutually exclusive. |
| `options` | `EcoSegmentedOption[]` | — | { label, value, count?, mark?, disabled? } — the count shows inside the option. |
| `mark` | `"p" \| "a" \| "l"` | — | On an option: colours it when selected (present, absent, late). |
| `tight` | `boolean` | false | Narrow padding for a control repeated down a column. |
| `label` | `string` | — | Accessible name of the group. |
| `disabled` | `boolean` | false | Disable every option. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `value / onChange` | `string \| number \| null` | null | The chosen value — options are mutually exclusive. |
| `options` | `EcoSegmentedOption[]` | — | { label, value, count?, mark?, disabled? } — the count shows inside the option. |
| `mark` | `"p" \| "a" \| "l"` | — | On an option: colours it when selected (present, absent, late). |
| `tight` | `boolean` | false | Narrow padding for a control repeated down a column. |
| `label` | `string` | — | Accessible name of the group. |
| `disabled` | `boolean` | false | Disable every option. |
