navius

Checkbox

A control that toggles between checked, unchecked, and indeterminate states.

Features

  • Full keyboard navigation.
  • Supports an indeterminate state (@bind-CheckedState with bool?).
  • Can be controlled (@bind-Checked) or uncontrolled (DefaultChecked).
  • Renders a hidden input so it participates in native form submission.
  • role="checkbox" with the correct aria-checked state (including "mixed").

Installation

Install the brain, or copy just this primitive in with the CLI.

Anatomy

Import the parts and assemble them.

API Reference

Contains all the parts of a checkbox. Renders a button.

Prop Type Default
Checked bool false
CheckedChanged EventCallback<bool> -
DefaultChecked bool false
CheckedState bool? -
CheckedStateChanged EventCallback<bool?> -
DefaultCheckedState bool? -
Disabled bool false
Required bool false
Name string? -
Value string "on"
ChildContent RenderFragment? -
Data attribute Values
[data-checked] Present when checked
[data-unchecked] Present when unchecked
[data-indeterminate] Present when indeterminate
[data-disabled] Present when disabled

Renders when the checkbox is in a checked or indeterminate state. Renders a span.

Prop Type Default
KeepMounted bool false
ChildContent RenderFragment? -
Data attribute Values
[data-checked] Present when checked
[data-unchecked] Present when unchecked
[data-indeterminate] Present when indeterminate
[data-disabled] Present when disabled

Accessibility

Adheres to the tri-state checkbox WAI-ARIA design pattern.

Key Description
Space Toggles the component's state.