Skip to content
GitHub11 stars

Provides shared state to a series of checkboxes.

Apples
<CheckboxGroupRoot aria-labelledby="@_id" Value="@(["fuji-apple"])" class="checkbox-group">
    <div class="checkbox-group-caption" id="@_id">
        Apples

Usage guidelines

Anatomy

Checkbox Group is composed together with Checkbox. Import the primitives and assemble the parts:

@using Blazix.Primitives

<CheckboxGroupRoot>
    <CheckboxRoot />
</CheckboxGroupRoot>

Examples

Labeling a checkbox group

Label the group with aria-labelledby and a sibling label element:

Using aria-labelledby to label a checkbox group
<div id="protocols-label">Allowed network protocols</div>
<CheckboxGroupRoot aria-labelledby="protocols-label">...</CheckboxGroupRoot>

An enclosing <label> is the simplest labeling pattern for each checkbox:

Using an enclosing label to label a checkbox
<label>
    <CheckboxRoot Value="http" />
    HTTP
</label>

Parent checkbox

A checkbox that controls the other checkboxes in a CheckboxGroupRoot can be created:

  1. Bind the group's Value.
  2. Pass the values of all the child checkboxes to the group's AllValues parameter.
  3. Set Parent on the parent CheckboxRoot.

The group sets the parent checkbox's indeterminate state when some, but not all, of the child checkboxes are checked.

<CheckboxGroupRoot aria-labelledby="@_id" @bind-Value="_value" AllValues="Fruits" class="checkbox-group-parent" style="margin-left: 1rem">
    <label class="checkbox-group-parent-item" id="@_id" style="margin-left: -1rem">
        <CheckboxRoot Parent="true" class="checkbox-group-parent-checkbox">

API Reference

CheckboxGroupRoot

Renders a <div> element.

ParameterTypeDefault
Value IReadOnlyList<string>? -
ValueChanged

Called with the new value when Value changes, for @bind-Value.

EventCallback<IReadOnlyList<string>?> -
OnValueChange

Runs before the value changes, with the reason; call Cancel() to keep it.

EventCallback<ValueChangeEventArgs<IReadOnlyList<string>>> -
AllValues IReadOnlyList<string>? -
Disabled

Whether the component should ignore user interaction.

bool false
Render RenderFragment<CheckboxGroupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-disabled

Present when the checkbox group is disabled.

-