Reference

RadioGroup

One choice of several, as native radio buttons under a legend: the arrow keys move between them, and .cards draws each as a card with its hint.

RadioGroup(bind: State, label: String, cards: Bool) { … }

Since 6.2.0

label

cards

Plan

Chosen: team

Example

wf

state plan = "team" RadioGroup(bind: plan, label: "Plan").cards { RadioGroup.Option("Free", value: "free", hint: "For trying it out") RadioGroup.Option("Team", value: "team", hint: "Up to 20 people, $12 each") RadioGroup.Option("Scale", value: "scale", hint: "Unlimited people, single sign-on") } Text("Chosen: {plan}").muted

As a plain list

wf

state billing = "monthly" RadioGroup(bind: billing, label: "Billing") { RadioGroup.Option("Monthly", value: "monthly") RadioGroup.Option("Yearly", value: "yearly", hint: "Two months free") }

Props

Props of RadioGroup
PropTypeUnsetMeaning

bind:

State (required)

—

The state it reads and writes: the chosen option's value: (a String, Number or Bool)

label:

String (required)

—

What is being chosen: drawn as the group's legend, which names it for a screen reader

cards:

Bool

false

Each option drawn as a card, its hint beneath its words. Written as a flag, .cards, or cards: true.

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.

.cards

Events

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

Slots

children

Parts

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

RadioGroup.Option

One choice: its words, its value, and a hint said with it.

RadioGroup.Option(_ label: String, value: String or Number or Bool, hint: String) { … }
Props of RadioGroup.Option
PropTypeUnsetMeaning

label

String (positional)

—

The option's words, beside its radio

value:

String or Number or Bool (required)

—

What bind: holds when it is chosen

hint:

String

none

A line beneath its words, read with the option (aria-description)

Drawn for it

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

Drawn for it
PartClassMeaning

RadioGroup.Legend

—

Its legend.

RadioGroup.Hint

—

An option's hint.

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