Checkbox
Checkbox input for boolean or multi-select form values.
Installation
Add the Checkbox component using the CLI:
Usage
The Checkbox component provides a boolean or multi-select form input. Use ChildContent for the label. Bind Checked for two-way state, or use CheckedChanged for one-way updates.
Examples
With Label
Place the label text in ChildContent. The entire label is clickable to toggle the checkbox.
Grouping
Use a container with multiple Checkbox components. Bind each via Checked and CheckedChanged to a shared collection (e.g. HashSet<string>) in the parent. No separate group component—the layout and parent state define the group.
Selected:
Alignment
Use the Alignment parameter to control how the checkbox aligns with its label when the label wraps to multiple lines. Options are VerticalAlignment.Top, VerticalAlignment.Center (default), and VerticalAlignment.Bottom.
Top
Center (default)
Bottom
Alignment with label and description
Use Alignment="VerticalAlignment.Top" when you have a main label with a description underneath. The checkbox aligns with the top of the label so it stays visually anchored to the primary text.
Disabled
Use the Disabled parameter to prevent interaction. The checkbox is dimmed and cannot be toggled.
Invalid state
Set Invalid="true" to show the invalid state. The checkbox gets a red border and ring, and the label text turns red. Use this when validation fails (e.g. a required checkbox that must be checked before submit).
API Reference
Checkbox
Checkbox input for boolean or multi-select form values.
Properties
| Name | Type | Description |
|---|---|---|
AdditionalAttributes |
Dictionary<string, Object> |
|
Alignment |
VerticalAlignment |
Vertical alignment of the checkbox relative to its label. |
Checked |
bool |
Whether the checkbox is checked. |
CheckedChanged |
EventCallback<bool> |
Callback invoked when the checked state changes. |
ChildContent |
RenderFragment |
Content to display alongside the checkbox (e.g., label). |
Class |
string |
|
Disabled |
bool |
Whether the checkbox is disabled. |
Invalid |
bool |
Whether the checkbox is in an invalid state. When true, sets aria-invalid="true" and applies invalid styling. |
Size |
Size |
The size of the checkbox. |
Events
| Name | Type | Description |
|---|---|---|
CheckedChanged |
EventCallback<bool> |
Callback invoked when the checked state changes. |
Methods
| Method | Returns | Description |
|---|---|---|
Equals |
bool |
|
GetHashCode |
int |
|
GetType |
Type |
|
SetParametersAsync |
Task |
|
ToString |
string |