Search 71 components and 72 controllers by name, category or description.
Switch
Native ARIA switch with old input, optional unchecked value and auto-submit
Switch rows
A native checkbox with role="switch", so it submits and validates like one. size takes default or sm.
Receive alerts on this device.
Managed by your identity provider.
{{-- A switch is a native checkbox with role="switch": it submits like one. --}}
<hw:field name="notifications" orientation="horizontal">
<hw:switch value="1" checked />
<hw:field.content>
<hw:field.title>Push notifications</hw:field.title>
<hw:field.description>Receive alerts on this device.</hw:field.description>
</hw:field.content>
</hw:field>
<hw:field name="beta" orientation="horizontal">
<hw:switch value="1" size="sm" />
<hw:field.label>Join the beta channel</hw:field.label>
</hw:field>
<hw:field name="sso" orientation="horizontal" disabled>
<hw:switch value="1" checked disabled />
<hw:field.content>
<hw:field.title>Enforce SSO</hw:field.title>
<hw:field.description>Managed by your identity provider.</hw:field.description>
</hw:field.content>
</hw:field>
unchecked-value
An unchecked checkbox submits nothing. unchecked-value renders a hidden input ahead of the switch so the key is always present — the difference between "off" and "not sent".
Posts marketing=0 when off instead of omitting the key.
{{-- An unchecked checkbox submits nothing at all. unchecked-value renders a hidden
input before the switch, so the request always carries a value for the key. --}}
<hw:field name="marketing" orientation="horizontal">
<hw:switch value="1" unchecked-value="0" />
<hw:field.content>
<hw:field.title>Marketing emails</hw:field.title>
<hw:field.description>Posts <code>marketing=0</code> when off instead of omitting the key.</hw:field.description>
</hw:field.content>
</hw:field>
Choice card
Wrap the whole hw:field in a hw:field.label to make the card clickable. The preset then styles checked, disabled and invalid from the field and switch state.
{{-- Wrapping the whole field in field.label turns the card into the click target,
and lets the preset style checked, disabled and invalid from the field state. --}}
<div class="grid gap-3 sm:max-w-md">
<hw:field.label>
<hw:field name="share_focus" orientation="horizontal">
<hw:field.content>
<hw:field.title>Share across devices</hw:field.title>
<hw:field.description>Focus is shared across devices, and turns off when you leave the app.</hw:field.description>
</hw:field.content>
<hw:switch value="1" checked />
</hw:field>
</hw:field.label>
<hw:field.label>
<hw:field name="legacy_sync" orientation="horizontal" disabled>
<hw:field.content>
<hw:field.title>Legacy sync</hw:field.title>
<hw:field.description>Retired in v2. Pass disabled to the field and to the switch.</hw:field.description>
</hw:field.content>
<hw:switch value="1" disabled />
</hw:field>
</hw:field.label>
</div>
auto-submit
Switches are discrete controls, so they submit immediately on change rather than waiting out a debounce.
off.{{-- Switches submit immediately on change, like every discrete control. --}}
<hw:form method="get" :action="route('components.switch')" auto-submit clean-query-params frame="switch-auto-submit-results">
<hw:field name="compact" orientation="horizontal">
<hw:switch value="1" :checked="request()->boolean('compact')" auto-submit />
<hw:field.content>
<hw:field.title>Compact layout</hw:field.title>
<hw:field.description>Toggling reloads the frame below straight away.</hw:field.description>
</hw:field.content>
</hw:field>
</hw:form>
<hw:frame id="switch-auto-submit-results" class="mt-4 block rounded-lg border bg-muted/30 p-4 text-sm">
Compact layout is <code>{{ request()->boolean('compact') ? 'on' : 'off' }}</code>.
</hw:frame>