Reference

Radio

One choice of a group; every radio bound to the same state is one group.

Radio(bind: State, value: String or Number or Bool, checked: Bool, …)

Before 5.0

checked

label

disabled

Chosen: standard

Example

wf

state shipping = "standard" Stack(gap: .sm) { Radio(bind: shipping, value: "standard", label: "Standard — 5 to 7 days, free") Radio(bind: shipping, value: "express", label: "Express — 2 days, $9") Radio(bind: shipping, value: "overnight", label: "Overnight — $24") Text("Chosen: {shipping}").muted }

One that cannot be chosen

wf

state size = "m" Radio(bind: size, value: "m", label: "Medium") Radio(bind: size, value: "xl", label: "Extra large (sold out)").disabled

Props

Props of Radio
PropTypeUnsetMeaning

bind:

State

The state shared by a group of radios: it holds the chosen radio's value:, and radios bound to one state are one group for the arrow keys

value:

String or Number or Bool

none

What bind: holds when this one is chosen, and what a form sends for it; a bound radio without one is never checked

checked:

Bool

false

Whether it is chosen, when no state is bound: shown, not written back. Written as a flag, .checked, or checked: true.

label:

String

none

The words after the button, which a press on also chooses; also its accessible name

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.

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.

.checked

.disabled

Events

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

DOM events Radio answers
EventSendsMeaning
on changeDOMThe value was committed

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-radio, stable across releases, so a stylesheet may target it.