View laravel-hotwire on GitHub
1M
v0.91.0
Search 71 components and 72 controllers by name, category or description.
Checkbox
Native checkbox with old input, validation, unchecked values and indeterminate state
Checkboxes
Inside a hw:field the checkbox inherits the name and derives its id, error key and ARIA wiring. Use field.label for a single line and field.content when the row needs a description.
Marketing updates
At most one email a month.
{{-- Inside a field the checkbox inherits the name and its ARIA wiring. --}}
<hw:field name="notifications" orientation="horizontal">
<hw:checkbox value="email" checked />
<hw:field.label>Email notifications</hw:field.label>
</hw:field>
<hw:field name="marketing" orientation="horizontal">
<hw:checkbox value="yes" />
<hw:field.content>
<hw:field.title>Marketing updates</hw:field.title>
<hw:field.description>At most one email a month.</hw:field.description>
</hw:field.content>
</hw:field>
<hw:field name="managed" orientation="horizontal" disabled>
<hw:checkbox value="yes" checked disabled />
<hw:field.label>Managed by your administrator</hw:field.label>
</hw:field>
Submitted values
unchecked-value guarantees the key is present when the box is off. indeterminate is a DOM property the checkbox controller sets — a third visual state, not a third value. Sharing an array name gives each box an id suffixed from its value.
Partially selected
Still submits 1 or nothing — the dash is presentation.
{{-- An unchecked checkbox submits nothing. unchecked-value renders a hidden input
before it, so the key is always present in the request. --}}
<hw:field name="terms" orientation="horizontal">
<hw:checkbox value="1" unchecked-value="0" />
<hw:field.label>Posts <code>terms=0</code> when off</hw:field.label>
</hw:field>
{{-- indeterminate is a DOM property, not an attribute — the checkbox controller
sets it. It is a visual third state, not a third submitted value. --}}
<hw:field name="select_all" orientation="horizontal">
<hw:checkbox value="1" indeterminate />
<hw:field.content>
<hw:field.title>Partially selected</hw:field.title>
<hw:field.description>Still submits <code>1</code> or nothing — the dash is presentation.</hw:field.description>
</hw:field.content>
</hw:field>
{{-- Several checkboxes under one array name; ids get the value appended. --}}
<fieldset class="grid gap-2">
<legend class="mb-1 text-sm font-medium">roles[] — ids role-admin, role-editor</legend>
<label class="flex items-center gap-2 text-sm">
<hw:checkbox name="roles[]" value="admin" checked />
Admin
</label>
<label class="flex items-center gap-2 text-sm">
<hw:checkbox name="roles[]" value="editor" />
Editor
</label>
</fieldset>