Skip to content

Segmented ​

A row of mutually exclusive options. stacked renders tall ratio-picker items with proportional artwork.

Examples ​

Row mode ​

moonbit
@sumi.segmented(
  items=[
    @sumi.SegmentedItem::new("2k", "2K", numeric=true),
    @sumi.SegmentedItem::new("4k", "4K", numeric=true, trailing=sparkle),
    @sumi.SegmentedItem::new("8k", "8K", numeric=true, trailing=sparkle),
  ],
  selected=current,
  on_select=set_res.map(v => _ => v),
)

Stacked ratio picker ​

moonbit
@sumi.segmented(
  stacked=true,
  items=[
    @sumi.SegmentedItem::new("16:9", "16:9", numeric=true,
      icon=@sumi.icon_ratio(width=16, height=9)),
    @sumi.SegmentedItem::new("1:1", "1:1", numeric=true,
      icon=@sumi.icon_ratio(width=1, height=1)),
  ],
  selected=current,
  on_select=set_ratio.map(v => _ => v),
)

API ​

segmented ​

NameTypeDefaultDescription
items *Array[SegmentedItem]—Option list
selected *String—Value of the selected option (controlled)
stackedBoolfalseTall icon-over-label layout
on_selectEmit[String]—Called with the value of the picked item
idString—Element id
classString—Extra class names
attrsAttrs—Extra HTML attributes
styleArray[String][]Extra inline styles

SegmentedItem::new ​

One option.

NameTypeDefaultDescription
valueString—
labelString—
iconHtml—Leading artwork (stacked mode)
trailingHtml—Trailing marker (e.g. a premium sparkle)
numericBoolfalseNumeric font rendering
disabledBoolfalseBlocks interaction and dims the control

* required (labelled) parameter — everything else is optional.