1. Reference
  2. Forms and input

<segmented-button>

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

Forms and input
segmented-button.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>
The snippet drawn by Hype Apps on a phone, in light mode The snippet drawn by Hype Apps on a phone, in dark mode
This snippet as Hype Apps draws it on a phone. It follows this page's light or dark theme.

Attributes

NameWhat it doesDefault
name Variable name for form scoping
string

Readings

NameWhat 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

This page is also Markdown, and all of HAM is in llms.txt.