Checkbox Group

Shared state and labeling for a set of related checkboxes.

EXAMPLEwasm · webgpu

This demo runs the real GPUI component on WebGPU, which this browser does not expose.

Try Chrome or Edge 113+, or Safari 26+. In Firefox, enable dom.webgpu.enabled.

You can also run it natively: cargo run -p showcase checkbox-group

The demo failed to start in this browser.

You can run it natively instead: cargo run -p showcase checkbox-group

Live examples are not supported on most mobile browsers yet — open this page on a desktop or tablet to run the demo.

Recent phones with WebGPU may manage it (downloads ~18 MB):

#Anatomy

Import the component's parts and compose them under its root:

use base_gpui::checkbox_group::{
    CheckboxGroup,
};

CheckboxGroup::new();
The anatomy is a structural overview. Parts with mutually exclusive modes may need separate instances; each part's section below documents its configuration.

#CheckboxGroup

Groups related child parts and coordinates their shared behavior.

Source

use base_gpui::checkbox_group::CheckboxGroup;

CheckboxGroup::new()
    .id("example-id")
    .default_value(/* values: impl IntoIterator<Item = impl Into<SharedString>> */)
    .value(/* values: impl IntoIterator<Item = impl Into<SharedString>> */)
    .all_values(/* values: impl IntoIterator<Item = impl Into<SharedString>> */)
    .disabled(true)
    .aria_label("aria label")
    .on_value_change(|/* callback arguments */| { /* handle change */ })
    .style_with_state(|/* callback arguments */| { /* handle change */ });

#Builders

BuilderSignature & description
.newpub fn new() -> Self

Creates a CheckboxGroup with its default configuration.

.childpub fn child(mut self, child: impl IntoElement) -> Self
  • child: impl IntoElement

Adds one typed child to this part.

.childrenpub fn children(mut self, children: impl IntoIterator<Item = impl IntoElement>) -> Self
  • children: impl IntoIterator<Item = impl IntoElement>

Adds multiple typed children in iteration order.

.child_anypub fn child_any(mut self, child: impl IntoElement) -> Self
  • child: impl IntoElement

Adds one arbitrary renderable child to this part.

.idpub fn id(mut self, id: impl Into<ElementId>) -> Self
  • id: impl Into<ElementId>

Sets the stable GPUI element identity. Use a unique value when multiple instances can appear in the same view.

.default_valuepub fn default_value(mut self, values: impl IntoIterator<Item = impl Into<SharedString>>,) -> Self
  • values: impl IntoIterator<Item = impl Into<SharedString>>

Sets the initial value for uncontrolled state. Later user changes are retained by the component.

.valuepub fn value(mut self, values: impl IntoIterator<Item = impl Into<SharedString>>) -> Self
  • values: impl IntoIterator<Item = impl Into<SharedString>>

Sets the current controlled value or the value represented by this part, depending on the part's role.

.all_valuespub fn all_values(mut self, values: impl IntoIterator<Item = impl Into<SharedString>>) -> Self
  • values: impl IntoIterator<Item = impl Into<SharedString>>

Sets the all values configuration for this part.

.disabledpub fn disabled(mut self, disabled: bool) -> Self
  • disabled: bool

When true, prevents user interaction with this part.

.aria_labelpub fn aria_label(mut self, aria_label: impl Into<SharedString>) -> Self
  • aria_label: impl Into<SharedString>

Sets a literal accessible name for this part.

.on_value_changepub fn on_value_change(mut self, on_value_change: impl Fn(Vec<SharedString>, &mut CheckboxGroupValueChangeDetails, &mut Window, &mut App) + 'static,) -> Self
  • on_value_change: impl Fn(Vec<SharedString>, &mut CheckboxGroupValueChangeDetails, &mut Window, &mut App) + 'static

Registers a callback invoked when value change occurs.

.style_with_statepub fn style_with_state(mut self, style: impl Fn(CheckboxGroupStyleState, Div) -> Div + 'static,) -> Self
  • style: impl Fn(CheckboxGroupStyleState, Div) -> Div + 'static,

Styles the part from its current behavioral state while preserving separation between behavior and visual design.

CheckboxGroup also supports the GPUI traits implemented in its source, such as standard styling or child composition.

#Accessibility

Keyboard interaction and accessibility semantics are implemented by the component, independently of visual styling. Known limitations caused by missing GPUI accessibility primitives are documented in the module source and are not silently approximated.

#Stability

Base GPUI is pre-1.0. Builder names and state types may evolve as GPUI and this port mature.