# <segmented-button>

A row of joined Material 3 segments that picks one option, published as a variable.

Category: Forms and input.

```ham
<column style="w-full gap-12">
    <text style="font-semibold">Map style</text>
    <segmented-button id="mode"
                      name="mode">
        <segment value="map"
                 icon="map"
                 label="Map"
                 selected="true"/>
        <segment value="satellite"
                 icon="satellite_alt"
                 label="Satellite"/>
        <segment value="terrain"
                 icon="terrain"
                 label="Terrain"/>
    </segmented-button>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/segmented-button-light.webp), [dark](https://hypeapps.dev/img/tags/segmented-button-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `name` | Variable name for form scoping |  |

## Readings

| Name | What it does |
|---|---|
| `count` | How many options the control offers. |
| `index` | The selected option's position, from 0; -1 when none. |
| `label` | The selected option's text; empty when none is selected. |
| `value` | The selected option's value; empty when none is selected. |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Guides and recipes that use it

- [Forms and state](https://hypeapps.dev/docs/guides/forms.md)

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<segment>`](https://hypeapps.dev/docs/reference/segment.md): One option in a segmented button: a value with a label, an icon or both.
- [`<button>`](https://hypeapps.dev/docs/reference/button.md): A tappable button that runs an action: a fetch, a navigation or a statement.
- [`<checkbox>`](https://hypeapps.dev/docs/reference/checkbox.md): A checkbox with a label; its state goes into a variable by name.
- [`<chip>`](https://hypeapps.dev/docs/reference/chip.md): A compact chip: a label, a filter that toggles, a single choice in a set, or an action.
- [`<color-picker>`](https://hypeapps.dev/docs/reference/color-picker.md): A color picker: a hue ring round a disc, with swatches; the chosen color goes into a variable.
- [`<data-cell>`](https://hypeapps.dev/docs/reference/data-cell.md): One cell of a data table row.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
