Skip to content

Dropdown Menu ​

A trigger-anchored menu with compact or rich items, section labels, separators and shortcut hints. Keyboard navigation and dismissal are handled by the theme's event layer.

Examples ​

Rich items ​

moonbit
@sumi.dropdown_menu(
  trigger=@sumi.button(variant=@sumi.Secondary, [
    @html.text("Polish"),
    @sumi.menu_chevron(),
  ]),
  items=[
    @sumi.SectionLabel("QUALITY"),
    @sumi.Item(@sumi.MenuItem::new(
      "standard", "Standard",
      description="Balanced wording for everyday drafts",
      icon=@sumi.icon_sparkle(size=16),
    )),
  ],
  open=is_open,
  on_open_change=set_open.map(v => _ => v),
  selected=current,
  on_select=set_choice.map(v => _ => v),
)

Compact with shortcuts ​

moonbit
items=[
  @sumi.Item(@sumi.MenuItem::new("rename", "Rename", shortcut="R")),
  @sumi.Item(@sumi.MenuItem::new("duplicate", "Duplicate",
    icon=@sumi.icon_layers(size=14), shortcut="⌘D")),
  @sumi.Separator,
  @sumi.Item(@sumi.MenuItem::new("delete", "Delete",
    icon=@sumi.icon_x(size=14), shortcut="⌫")),
]

API ​

NameTypeDefaultDescription
items *Array[MenuEntry]—Menu content — Item, Separator, SectionLabel
trigger *Html—The anchor element
open *Bool—Whether the overlay is open (controlled)
on_open_changeEmit[Bool]—Called when the open state should change
selectedString—Value of the currently selected item
on_selectEmit[String]—Called with the value of the picked item
alignMenuAlignStartHorizontal alignment against the trigger
sideMenuSideBottomOpen above or below the trigger
idString—Element id
classString—Extra class names
attrsAttrs—Extra HTML attributes
styleArray[String][]Extra inline styles
trigger_styleArray[String][]Styles for the trigger wrapper
menu_styleArray[String][]Styles for the floating panel

The rotating trigger chevron (180° while open).

NameTypeDefaultDescription
sizeInt12

One menu item.

NameTypeDefaultDescription
valueString—
labelString—
descriptionString—Secondary line (rich layout)
iconHtml—Leading icon
shortcutString—Right-aligned shortcut hint
disabledBoolfalseBlocks interaction and dims the control
VariantDescription
StartAlign the panel's left edge to the trigger
EndAlign the panel's right edge to the trigger
VariantDescription
BottomOpen below the trigger (default)
TopOpen above the trigger (input docks)

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