Reference

Menubar

File, Edit and View, as in a desktop app: one Tab stop, the arrow keys along it; Down or Enter opens a menu, and with one open Left and Right open the one beside it.

Menubar(label: String) { … }

Since 6.2.0

label

Pick a command

Example

wf

state said = "Pick a command" Menubar(label: "Editor") { Menubar.Menu("File") { Menu.Item(shortcut: "mod+n") { on click { said = "New file" } Text("New file") } Menu.Item(shortcut: "mod+o") { on click { said = "Open…" } Text("Open…") } Menu.Divider Menu.Item(shortcut: "mod+s") { on click { said = "Saved" } Text("Save") } } Menubar.Menu("Edit") { Menu.Item(shortcut: "mod+z") { on click { said = "Undo" } Text("Undo") } Menu.Item(shortcut: "mod+shift+z") { on click { said = "Redo" } Text("Redo") } } Menubar.Menu("View") { Menu.Sub(label: "Zoom") { Menu.Item(shortcut: "mod+=") { on click { said = "Zoom in" } Text("Zoom in") } Menu.Item(shortcut: "mod+-") { on click { said = "Zoom out" } Text("Zoom out") } } } } Text(said).muted.sm

Props

Props of Menubar
PropTypeUnsetMeaning

label:

String

none

The bar's accessible name (aria-label on its menubar)

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

No flags of its own.

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

children

Parts

The parts of Menubar are written under its name, inside it. Each is described here, with what it takes.

One menu of the bar: its button's words, and its Menu.Items, Menu.Subs and Menu.Dividers.

Menubar.Menu(_ label: String) { … }
Props of Menubar.Menu
PropTypeUnsetMeaning

label

String (positional)

—

The words on its button, and the name of the menu it opens

Renders with the class wf-menubar, stable across releases, so a stylesheet may target it.