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
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
state size = "m"
Radio(bind: size, value: "m", label: "Medium")
Radio(bind: size, value: "xl", label: "Extra large (sold out)").disabled
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State | The state shared by a group of radios: it holds the chosen radio's | |
value: | String or Number or Bool | none | What |
checked: | Bool | false | Whether it is chosen, when no state is bound: shown, not written back. Written as a flag, |
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, |
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.
| Event | Sends | Meaning |
|---|---|---|
on change | DOM | The 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.