Skip to content

Select ​

An input-look trigger over a compact menu pinned to the trigger width. Shares MenuItem with dropdown menus.

Examples ​

Basic usage ​

moonbit
@sumi.select(
  options=[
    @sumi.MenuItem::new("png", "PNG"),
    @sumi.MenuItem::new("jpg", "JPG"),
    @sumi.MenuItem::new("webp", "WebP"),
  ],
  value=current,
  placeholder="Export format",
  open=is_open,
  on_open_change=set_open.map(v => _ => v),
  on_select=set_format.map(v => _ => v),
)

Filter trigger ​

moonbit
@sumi.select(
  options=[
    @sumi.MenuItem::new("design", "Design"),
    @sumi.MenuItem::new("engineering", "Engineering"),
    @sumi.MenuItem::new("marketing", "Marketing"),
  ],
  value=current,
  placeholder="Team",
  open=is_open,
  on_open_change=set_open.map(v => _ => v),
  on_select=set_team.map(v => _ => v),
  variant=Filter,
  on_clear=set_team(_ => ""),
)

API ​

select ​

NameTypeDefaultDescription
options *Array[MenuItem]—Option list
value *String—Selected value (controlled)
placeholderString"Select"Placeholder text
open *Bool—Whether the overlay is open (controlled)
on_open_changeEmit[Bool]—Called when the open state should change
on_selectEmit[String]—Called with the value of the picked item
variantSelectVariantFormForm input look, Filter compact toolbar trigger
on_clearCmd—Filter variant: emitted by the clear affordance
disabledBoolfalseBlocks interaction and dims the control
idString—Element id
classString—Extra class names
attrsAttrs—Extra HTML attributes
styleArray[String][]Extra inline styles

One menu option.

SelectVariant ​

VariantDescription
FormInput-look trigger pinned to full width (default)
FilterCompact trigger naming the filter until a value is set

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