Reference

Select

Drop-down of Select.Option children.

Select(bind: State, value: String or Number, label: String, …) { … }

Before 5.0

label

hint

disabled

multiple

Where your data is stored.

Chosen: eu-west

Example

wf

state region = "eu-west" Select(bind: region, label: "Region", hint: "Where your data is stored.") { Select.Option("Europe (Ireland)", value: "eu-west") Select.Option("US East (Virginia)", value: "us-east") Select.Option("Asia Pacific (Tokyo)", value: "ap-northeast") } Text("Chosen: {region}").muted

With an error message

wf

state role = "" derived roleError = if role == "" { "Choose a role for this person." } else { "" } Select(bind: role, label: "Role", error: roleError) { Select.Option("Choose…", value: "") Select.Option("Viewer", value: "viewer") Select.Option("Editor", value: "editor") Select.Option("Owner", value: "owner") }

Disabled

wf

state plan = "team" Select(bind: plan, label: "Plan").disabled { Select.Option("Free", value: "free") Select.Option("Team", value: "team") }

Props

Props of Select
PropTypeUnsetMeaning

bind:

State

The state it reads and writes: the chosen option's value: as it was written (a String, Number or Bool), or its label when it has none

value:

String or Number

the first option

The option chosen at first, by its value, when no state is bound

label:

String

none

Visible label; also the control's accessible name

hint:

String

none

Help text under the control, linked to it by aria-describedby

error:

String

none

Error text (a string; empty when there is none): announced as it appears and sets aria-invalid

disabled:

Bool

false

Whether the control is inert: it cannot be focused or changed, and a form does not send it. Written as a flag, .disabled, or disabled: true.

multiple:

Bool

false

A list box that takes several choices; a bound [String] state holds every one chosen. Written as a flag, .multiple, or multiple: true.

Attribute families: global, aria, data, input. 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.

.disabled

.multiple

Events

The DOM events it is drawn to answer. Any other DOM event works too, in an on … { } handler.

DOM events Select answers
EventSendsMeaning
on changeDOMThe value was committed
on focusDOMThe element received focus
on blurDOMThe element lost focus

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

Slots

children

Parts

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

Select.Option

One choice: the visible label, and the value sent with the form.

Select.Option(_ label: String, value: String or Number or Bool)
Props of Select.Option
PropTypeUnsetMeaning

label

String (positional)

—

The words the option shows; also its value when it has no value:

value:

String or Number or Bool

its label

What bind: holds when this one is chosen, kept as written (String, Number or Bool)

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