Skip to content

Checkbox

The Checkbox widget displays a toggleable checked/unchecked/indeterminate state with an optional label.

Basic Usage

Create a checkbox with the Checkbox() extension method. Use OnToggled() to handle state changes.

csharp

Key features:

  • Click or press Space/Enter to toggle
  • Use Label() to add descriptive text
  • Manage state externally (checkboxes are stateless widgets)

States

Checkboxes support three visual states:

csharp
StateDisplayUsage
Unchecked[ ]Default, option not selected
Checked[x]Option is selected
Indeterminate[-]Partial selection (e.g., some children selected)

Fluent API

MethodDescription
Checked()Set to checked state
Unchecked()Set to unchecked state
Indeterminate()Set to indeterminate state
Label(string)Add label text after the checkbox
OnToggled(handler)Handle toggle events

Keyboard Support

KeyAction
SpaceToggle the checkbox
EnterToggle the checkbox
TabMove to next focusable widget
  • ToggleSwitch — On/off switch with visual feedback
  • Tree — Hierarchical lists with multi-select checkboxes
  • Button — Clickable actions

Released under the MIT License.