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

wf

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

wf

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

Props of Combobox
PropTypeUnsetMeaning

bind:

State (required)

—

The state it reads and writes: the chosen option's key (the option itself without key:), or with .multiple a list of keys in the order chosen

options:

[Item]

none

Every option, filtered as the reader types to those whose words contain what is typed, case ignored; use this or search:

search:

(String) -> [Item] or (String) -> [Item]!

none

Options asked for as the reader types, each time the typing rests for debounce:: a function of the text giving a list, or an endpoint's call (q => Geo.cities(q: q)), whose .ok list is shown and whose failure shows none

text:

(Item) -> String (required)

—

An option's words, shown in the list and in the field once chosen: p => p.name

key:

(Item) -> String or (Item) -> Number

the option itself

What tells two options apart, and what bind: holds: p => p.id

debounce:

Number or Duration

200ms

How long the typing must rest before search: is asked: a Duration (250.ms) or milliseconds

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, .multiple, or multiple: true.

label:

String (required)

—

Its name for a screen reader: the field's and the list's (aria-label)

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.