1. Reference
  2. Forms and input

<segment>

One option in a segmented button: a value with a label, an icon or both.

Forms and input
segment.ham
<column style="w-full gap-12">
    <segmented-button name="view">
        <segment value="day"
                 label="Day"/>
        <segment value="week"
                 label="Week"
                 selected="true"/>
        <segment value="month"
                 label="Month"/>
    </segmented-button>
    <text @text="'Showing the ' + $view"
          style="muted"></text>
</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
icon Icon name
string
label Segment label (defaults to value)
string
selected Initially selected
boolean
false
value Segment value
string

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.