Reference
Combobox
A text field that offers what matches as the reader types: from options:, or search: asked of a server. The arrow keys go through the offers, Enter takes one, Escape closes them; .multiple keeps several, each a chip Backspace takes back. option(o) { … } draws an offer; empty { … } shows when nothing matches.
Combobox(bind: State, options: [Item], search: (String) -> [Item] or (String) -> [Item]!, …)
Since 6.2.0
multiple
label
placeholder
Chosen: lis
Example
state city = "lis"
Combobox(bind: city, options: [
{ id: "ams", name: "Amsterdam" },
{ id: "ber", name: "Berlin" },
{ id: "lis", name: "Lisbon" },
{ id: "mad", name: "Madrid" },
{ id: "par", name: "Paris" },
], text: c => c.name, key: c => c.id, label: "City", placeholder: "Type a city")
Text("Chosen: {city}").muted
Several, each a chip
state reviewers: [String] = ["ada"]
Combobox(bind: reviewers, options: [
{ id: "ada", name: "Ada Lovelace" },
{ id: "grace", name: "Grace Hopper" },
{ id: "alan", name: "Alan Turing" },
], text: p => p.name, key: p => p.id, label: "Reviewers").multiple
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State (required) | — | The state it reads and writes: the chosen option's key (the option itself without |
options: | [Item] | none | Every option, filtered as the reader types to those whose words contain what is typed, case ignored; use this or |
search: | (String) -> [Item] or (String) -> [Item]! | none | Options asked for as the reader types, each time the typing rests for |
text: | (Item) -> String (required) | — | An option's words, shown in the list and in the field once chosen: |
key: | (Item) -> String or (Item) -> Number | the option itself | What tells two options apart, and what |
debounce: | Number or Duration | 200ms | How long the typing must rest before |
multiple: | Bool | false | Several at once, each a chip with a button to take it out; Backspace in the empty field takes the last back. Written as a flag, |
label: | String (required) | — | Its name for a screen reader: the field's and the list's ( |
placeholder: | String | none | Shown in the field while it is empty |
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.
.multiple
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-combobox, stable across releases, so a stylesheet may target it.