Reference

Field

A label, a hint and an error around a control of your own: the first control in its block is named by the label and described by the hint and the error, and marked invalid while there is one.

Field(label: String, hint: String, error: String) { … }

Since 6.2.0

label

hint

Used for buttons and links.

Chosen: #0f766e

Example

wf

state color = "#0f766e" derived colorError = if color == "#ffffff" { "White disappears on the page." } else { "" } Field(label: "Brand colour", hint: "Used for buttons and links.", error: colorError) { ColorPicker(bind: color, label: "Brand colour", swatches: ["#0f766e", "#1d4ed8", "#b91c1c", "#ffffff"]) } Text("Chosen: {color}").muted

Around a control of your own

wf

state plan = "team" Field(label: "Plan", hint: "You can change it at any time.") { ToggleGroup(bind: plan, label: "Plan") { ToggleGroup.Item("Free", value: "free") ToggleGroup.Item("Team", value: "team") ToggleGroup.Item("Scale", value: "scale") } }

Props

Props of Field
PropTypeUnsetMeaning

label:

String

none

The label above the control; it names the first control in the block (aria-labelledby), and a press on it focuses that control

hint:

String

none

Help text under the control, linked to the first control in the block by aria-describedby

error:

String

none

Error text under the control: null or empty for none; while there is one it shows, is announced, and marks the control aria-invalid

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

Drawn for it

What Field draws itself, by the class a stylesheet can select. They are not written.

Drawn for it
PartClassMeaning

Field.Label

—

Its label.

Field.Hint

—

Its hint.

Field.Error

—

Its error, announced as it appears.

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