Reference
Dropdown
Button that opens a menu of Dropdown.Items.
Dropdown(_ label: String) { … }
Before 5.0
label
Nothing chosen
Example
state said = "Nothing chosen"
Dropdown("Actions") {
Dropdown.Item { Button("Duplicate") { on click { said = "Duplicated" } } }
Dropdown.Item { Button("Rename") { on click { said = "Renamed" } } }
Dropdown.Divider
Dropdown.Item { Button("Archive").danger { on click { said = "Archived" } } }
}
Text(said).muted
Items of plain text
Dropdown("Sort by") {
Dropdown.Item { Text("Newest") }
Dropdown.Item { Text("Oldest") }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
label | String (positional) | Menu | The words of the button that opens its menu; the first argument, |
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 Dropdown are written under its name, inside it. Each is described here, with what it takes.
Dropdown.Item
One entry of the menu.
Dropdown.Item { … }
Dropdown.Divider
A rule between groups of entries.
Dropdown.Divider
Renders with the class wf-dropdown, stable across releases, so a stylesheet may target it.