Toggle
Sourcecomponents/Toggle.astro
Overview
An on/off switch for an instant setting — the change takes effect the moment you flip it, no Save. Five states — off, hover, on, focus and disabled — on light, dark & image.
On light
off
hover
on
focus
disabled
On dark
off
hover
on
focus
disabled
On image
off
hover
on
focus
disabled
With a label
Put the setting name to the right; the whole row is clickable.
Setting row
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
checked | boolean | false | On by default. |
disabled | boolean | false | Dims and blocks the switch. |
name | string | — | Form field name (if submitted). |
surface | 'light' | 'dark' | 'light' | Dark surface treatment. |
Usage
Use it for a setting that applies immediately. Label goes in the slot.
<Toggle name="notify" checked>Email notifications</Toggle>
<Toggle />