Checkbox Group
Renders a group of checkboxes from an options array or from rich <hw:checkbox-group.item> children, with optional
"select-all" master checkbox via the checkbox-select-all Stimulus controller.
Each checkbox gets a unique id derived from the group name and option value. Inside a Field that owns the group, all
checkboxes share the same aria-describedby pointing to the group's error element.
Flat (non-associative) options arrays are automatically normalized: ['main', 'dev'] becomes
['main' => 'main', 'dev' => 'dev'].
Quick example
<hw:checkbox-group
name="user_ids[]"
:options="$users->pluck('name', 'id')->toArray()"
select-all
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string|null |
— | Input name. Auto-normalized to foo[] if you pass foo (see below) |
options |
array |
[] |
[value => label] pairs |
selected |
array |
[] |
Values that should be checked |
select-all |
bool |
false |
Renders a master checkbox that toggles all items |
disable-indeterminate |
bool |
false |
Keep the select-all checkbox binary when some items are checked |
select-all-label |
string|null |
"Select all" |
Custom label for the master checkbox |
orientation |
string |
"vertical" |
vertical or horizontal, matching <hw:radio-group> |
disabled |
bool |
false |
Disables every generated checkbox and rich item by default |
class |
string |
"" |
Merged on each checkbox <input> |
wrapper-class |
string |
"" |
Merged on the wrapper <div> |
label-class |
string |
"" |
Merged on each item <label> |
old |
bool |
true |
When true, merges old() input over selected |
auto-submit |
bool|string |
false |
Add auto-submit wiring to each item checkbox |
auto-submit-delay |
int|string|null |
null |
Per-field debounce override when auto-submit="debounced" is used |
id |
string|null |
derived | Base id for per-checkbox ids and error reference |
errorKey |
string|null |
derived | Override when HTML name ≠ Laravel validation key |
Name auto-normalization
Checkbox groups submit one HTTP field per checked item. PHP only collects them into an array when the name ends in
[] — otherwise it silently keeps only the last submitted value. To prevent this footgun, the component appends []
automatically when missing:
{{-- These render identically --}}
<hw:checkbox-group name="ids" :options="$opts" />
<hw:checkbox-group name="ids[]" :options="$opts" />
Both produce <input ... name="ids[]" ...>. In debug mode (APP_DEBUG=true, non-testing env), passing name="ids"
triggers an E_USER_NOTICE so you can tighten the call site. Validation keys and per-checkbox ids are unaffected —
they're always derived from the unbracketed name (ids, ids-1).
ARIA
Each checkbox (including the select-all master) emits:
id="{baseId}-{valueSlug}"— unique per checkbox (e.g.roles-admin,roles-editor)aria-invalid="true"anddata-invalidwhen the field has validation errors
Inside a Field that owns the group, checkboxes also emit aria-describedby="{baseId}-error" pointing to the group's
error element. Standalone groups do not invent an error reference; pass aria-describedby explicitly when rendering a
separate error node.
The select-all checkbox gets id="{baseId}-all".
Without select-all
<hw:checkbox-group
name="roles[]"
:options="['admin' => 'Admin', 'editor' => 'Editor', 'viewer' => 'Viewer']"
:selected="$user->roles ?? []"
/>
The wrapper renders data-orientation="vertical" by default and accepts orientation="horizontal", matching
<hw:radio-group>. Each checkbox renders inside a <label data-slot="checkbox-group-item"> with the option label
wrapped in data-slot="checkbox-group-item-content", matching the item spacing used by <hw:radio-group>.
Rich items
Use <hw:checkbox-group.item> when each option needs custom markup. The item inherits name, selected, old,
errorKey, select-all, and auto-submit from the parent group.
Explicit name, id, error-key, and disabled props on an item take precedence over inherited group and Field
context.
<hw:checkbox-group name="roles[]" :selected="$user->roles ?? []" select-all>
<hw:checkbox-group.item value="admin">
<span class="font-medium">Admin</span>
<span class="text-muted-foreground">Can manage billing and users.</span>
</hw:checkbox-group.item>
<hw:checkbox-group.item value="editor">
<span class="font-medium">Editor</span>
<span class="text-muted-foreground">Can publish and update content.</span>
</hw:checkbox-group.item>
</hw:checkbox-group>
You can combine options and rich items in the same group; options render first, then the slot content.
An item must render inside its owning <hw:checkbox-group> in the same Blade tree. For Turbo Streams, replace the
item's inner content or render the owning group instead of streaming a standalone <hw:checkbox-group.item>.
With select-all
When select-all is enabled, the wrapper gets data-controller="checkbox-select-all", the master checkbox gets
data-checkbox-select-all-target="checkboxAll", and each item gets data-checkbox-select-all-target="checkbox". The
controller handles indeterminate state automatically.
<hw:checkbox-group
name="tags[]"
:options="[1 => 'Laravel', 2 => 'Hotwire', 3 => 'Stimulus']"
select-all
select-all-label="All tags"
/>
Flat options arrays
Non-associative arrays are normalized, so values serve as both keys and labels:
<hw:checkbox-group
name="branchs[]"
:options="['main', 'dev', 'next']"
:selected="['main', 'dev']"
/>
This renders value="main", value="dev", value="next" — not value="0", value="1", value="2".
Inheriting from <hw:field>
When inside <hw:field>, name, id, and errorKey are inherited from the scoped Field context:
<hw:field name="roles[]" id="role-options">
<hw:field.title>Roles</hw:field.title>
<hw:checkbox-group aria-label="Roles" :options="[1 => 'Admin', 2 => 'Editor']" />
</hw:field>
Disable indeterminate state
The select-all checkbox shows an indeterminate (dash) state when some — but not all — items are checked. To disable this behavior and only toggle between fully checked and unchecked:
<hw:checkbox-group
name="tags[]"
:options="[1 => 'Laravel', 2 => 'Hotwire']"
select-all
disable-indeterminate
/>
Auto-submit
auto-submit adds auto-submit wiring to every item checkbox. The auto-submit controller should live on an
ancestor form:
<hw:form auto-submit>
<hw:checkbox-group name="tags[]" :options="$tags" auto-submit />
</hw:form>
Groups submit immediately by default. Use auto-submit="debounced" auto-submit-delay="..." to debounce every item in the
group.
Controller integrations
hotwire:check looks for checkbox-select-all when you use the select-all prop and auto-submit when you use the
auto-submit prop.
Styling hooks
The component exposes stable data-slot hooks for preset and application CSS:
data-slot="checkbox-group"data-slot="checkbox-group-item"data-slot="checkbox-group-input"data-slot="checkbox-group-item-content"