Forms

Checkbox Group

A group of checkboxes with shared state.

Rust
1use herogpui::components::checkbox::CheckboxGroup;

Usage

Option labels use 14px/20px medium text; descriptions use 12px/16px regular text.

Rust
1use herogpui::prelude::CheckboxGroup;
2
3CheckboxGroup::new("checkbox-group", group_options())
4    .label("Notifications")

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

CheckboxGroup

Checkbox Group is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Checkbox Group uses.

Styling

Checkbox Group styling
StyleDescription
text_size + line_heightOption labels use 14px/20px medium text; descriptions use 12px/16px regular text.
CheckboxGroup::render flex_col + gap(px(16.))Group root stacks label, options and help/error text.
option list gap(px(16.))Sixteen-pixel spacing between option rows.
label_el flex_col + gap(px(4.))Per-option label/help stack.
Checkbox rowOption control and text row.

API reference

Builders

Checkbox Group builders
BuilderTypeDefaultDescription
value(keys)string[]Current selected values (controlled).
default_value(keys)string[]Initial selected values (uncontrolled).
on_change(callback)Fn(value: string[]) -> ()Handler called with the complete selected set.
is_disabled(bool)boolfalseDisables every option and omits the group from form submission.
is_required(bool)boolfalseRequires at least one enabled option to be selected.
is_read_only(bool)boolfalseKeeps enabled options focusable while preventing changes.
is_invalid(bool)boolfalseMarks the group and every option invalid.
name(value)stringSubmitted form field name for the selected values.
new(id, options)id, optionsCompound group content; takes options plus label/description/error builders.

Parts

Checkbox Group parts
PartDescription
CheckboxGroupGroup value, validation, form and option composition owner.
CheckboxGroupGroup label with required, disabled and invalid state.
CheckboxGroupOptional group or per-option help text.
CheckboxGroupOne generated checkbox per option.
CheckboxGroupOption label and optional description content.
CheckboxGroupSelection control inherited from Checkbox.
CheckboxGroupSelection mark inherited from Checkbox.
CheckboxGroupGroup validation message rendered in place of the description.

States

Checkbox Group states
BuilderStateDescription
CheckboxGroup::is_disabledDisabledEvery option is disabled and omitted from the successful form value.
CheckboxGroup::is_read_only -> Checkbox::is_read_onlyRead onlyOptions remain focusable but cannot toggle.
is_invalid + error_messageInvalidDanger treatment propagates to each option and the field error.
FormField::is_requiredRequiredNative form validation requires one enabled selected value.
util::controlled(Some(value))ControlledThe caller owns the selected set; callbacks report without mutating behind it.
util::controlled(None) + restoreUncontrolledThe group owns and resets its keyed selected set.