Checkbox
An easily stylable checkbox component.
Usage guidelines
- Form controls must have an accessible name: give it one with a
<label>element or the Field parts. See Labeling a checkbox.
Anatomy
Import the primitives and assemble the parts:
@using Blazix.Primitives
<CheckboxRoot>
<CheckboxIndicator />
</CheckboxRoot>Examples
Labeling a checkbox
An enclosing <label> is the simplest labeling pattern:
<label>
<CheckboxRoot />
Accept terms and conditions
</label>CheckboxRoot renders a <span> with a hidden native <input> beside
it, which carries the name, value and validity so the checkbox submits with forms. To label it with a sibling
<label>, point the label's for at the hidden input's id, set with
InputId:
<div>
<label for="notifications-checkbox">Enable notifications</label>
<CheckboxRoot InputId="notifications-checkbox">
<CheckboxIndicator />
</CheckboxRoot>
</div>API Reference
CheckboxRoot
Renders a <span> element.
Other attributes are passed to the element it renders.
CheckboxIndicator
Renders a <span> element.
Other attributes are passed to the element it renders.