Reference
CheckboxGroup
Check boxes under a legend whose bind: is the list of the values ticked, with all: a box above them for every one at once — ticked when all are, mixed when some are.
CheckboxGroup(bind: State, label: String, all: String) { … }
Since 6.2.0
label
all
Chosen: email
Example
state channels: [String] = ["email"]
CheckboxGroup(bind: channels, label: "Notify me by", all: "Every channel") {
CheckboxGroup.Option("Email", value: "email")
CheckboxGroup.Option("Text message", value: "sms")
CheckboxGroup.Option("Push notification", value: "push")
}
Text("Chosen: {channels.join(", ")}").muted
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State (required) | — | The list state it reads and writes: the |
label: | String (required) | — | What is being chosen: drawn as the group's legend, which names it for a screen reader |
all: | String | none | The words of a first box that ticks every option or none, mixed while some are ticked; only when the options are written out, not drawn by a |
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
Parts
The parts of CheckboxGroup are written under its name, inside it. Each is described here, with what it takes.
CheckboxGroup.Option
One box: its words and its value.
CheckboxGroup.Option(_ label: String, value: String or Number or Bool)
| Prop | Type | Unset | Meaning |
|---|---|---|---|
label | String (positional) | — | The option's words, beside its box; also its value when it has no |
value: | String or Number or Bool | its label | What the list holds while it is ticked |
Drawn for it
What CheckboxGroup draws itself, by the class a stylesheet can select. They are not written.
| Part | Class | Meaning |
|---|---|---|
CheckboxGroup.Legend | — | Its legend. |
Renders with the class wf-checkbox-group, stable across releases, so a stylesheet may target it.