schaefersoft/laravel-headless-ui
Accessible, headless toggle (switch) with keyboard support and form syncing.

Blade components: x-hui::toggle, x-hui::toggle.thumb
<x-hui::toggle checked name="my_toggle">
<x-hui::toggle.thumb/>
</x-hui::toggle>
<x-hui::toggle disabled name="my_toggle">
<x-hui::toggle.thumb/>
</x-hui::toggle>
The thumb can contain child elements such as icons.

<x-hui::toggle name="my_toggle">
<x-hui::toggle.thumb>
<!-- Add any content - e.g. SVG icon -->
</x-hui::toggle.thumb>
</x-hui::toggle>
When the name prop is set, the toggle renders a hidden checkbox that stays in sync with the toggle state. This allows the value to be submitted with standard form submissions.
Use ARIA attributes (aria-checked, aria-disabled) to style the toggle.
[!NOTE] Minimal defaults are provided (inline-block, border-radius, thumb animation). All are overridable.
.hui-toggle {
background-color: lightgray;
}
.hui-toggle[aria-checked="true"] {
background-color: blue;
}
.hui-toggle .hui-toggle-thumb {
background-color: white;
}
.hui-toggle[aria-checked="true"] .hui-toggle-thumb {
filter: drop-shadow(/* add your drop shadow here */);
}
<x-hui::toggle class="group bg-zinc-200 aria-checked:bg-green-500">
<x-hui::toggle.thumb class="group-aria-checked:drop-shadow-green-700 group-aria-checked:drop-shadow-lg/60"/>
</x-hui::toggle>
| Prop | Type | Default | Description |
|---|---|---|---|
class |
string |
"" |
Custom classes for the toggle. |
checked |
boolean |
false |
Initial checked state; reflected to aria-checked. |
disabled |
boolean |
false |
Disables interaction; reflected to aria-disabled and removes focus (tabindex="-1"). |
name |
string |
null |
When set, renders a hidden checkbox and keeps it in sync. |
[!NOTE] Allows all valid HTML
<div/>attributes (class, style, data-, aria-, etc.).
| Prop | Type | Default | Description |
|---|---|---|---|
class |
string |
"" |
Custom classes for the thumb. |
[!NOTE] Renders a
<div/>marked witharia-hidden="true". It mirrorsaria-checked/aria-disabledfor styling.
| Key | Action |
|---|---|
Space |
Toggle the switch when focused |
role="switch" with aria-checked reflecting the current state.aria-disabled="true" and removed from tab order (tabindex="-1").aria-hidden="true" as it is purely decorative.How can I help you explore Laravel packages today?