Toggle
Toggles handle binary choices without forcing users through a full form submit or dropdown flow.
Installation
Add the toggle component to your project:
Usage
Default Toggle
Toggle
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Toggle
Full preview from the registry iframe.
Loading preview...
Checked State
Toggle
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Toggle
Full preview from the registry iframe.
Loading preview...
With Description
Toggle
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Toggle
Full preview from the registry iframe.
Loading preview...
Sizes
Toggle
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Toggle
Full preview from the registry iframe.
Loading preview...
Toggle
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Toggle
Full preview from the registry iframe.
Loading preview...
Disabled
Toggle
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Toggle
Full preview from the registry iframe.
Loading preview...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string | null |
null |
Optional field name for form and Livewire binding |
checked |
bool |
false |
Initial checked state |
value |
mixed |
null |
Alternate incoming value used to resolve checked state |
label |
string | null |
null |
Optional visible label |
description |
string | null |
null |
Supporting text shown below the label |
size |
string |
'md' |
Toggle size: sm, md, or lg |
disabled |
bool |
false |
Disables interaction |
required |
bool |
false |
Marks the field as required in forms |
Example Structure
<x-ui.toggle
name="notifications"
label="Email notifications"
description="Keep me informed about releases and account activity."
:checked="true"
/>
Accessibility
- Role - Uses
role="switch"witharia-checked - Keyboard - Supports
SpaceandEnter - Labels - Works with visible labels and required indicators
- Focus states - Includes visible focus ring styles
Next Steps
- Explore Range Slider component
- Learn about Tooltip component
- View Input component