Skip to content

Switch

Forms

An on/off toggle switch. Used for boolean settings with immediate effect.

atlas-switch

Examples

Basic

A switch toggles a setting on or off immediately. Bind [(checked)] ; inputId plus <label atlasLabel for> makes the visible text its name and a click target.

Weekly summary of activity.

Alerts on this device.

Described and disabled

ariaDescribedBy links the hint under each setting, so it is read with the switch. A setting that cannot change right now is disabled , and its hint says why.

Runs at 02:00, keeps 30 days.

Only an owner can change this.

Dependent settings with Signal Forms

Bound with [formField] , a switch follows its field, including disabled : the disabled rule turns "Product news" off while email notifications are off.

Email: true, product news: false

API

Generated from the library source, so it always matches the code.

AtlasSwitchComponent atlas-switch

InputTypeDefaultDescription
checked two-waybooleanfalse Whether the switch is on (two-way: [(checked)] , or Signal Forms [field] ).
disabled booleanfalse Disables the control. Set automatically when the control is bound with Signal Forms [field] .
errors readonly ValidationError.WithOptionalFieldTree[][] Validation errors of the bound field. Set by Signal Forms [field] .
required booleanfalse Whether a value is required. Set by Signal Forms [field] .
invalid booleanfalse Whether the field is invalid. Set by Signal Forms [field] .
touched booleanfalse Whether the user has interacted with the field. Set by Signal Forms [field] .
readonly booleanfalse Whether the field is read-only. Set by Signal Forms [field] .
pending booleanfalse Whether async validation is running. Set by Signal Forms [field] .
name string'' Name of the field. Set by Signal Forms [field] .
ariaLabel string | nullnull Accessible name when no visible label names the control (use one or the other, WCAG 2.5.3).
inputId string | undefinedundefinedid of the inner button, so a visible <label atlasLabel for="…"> names it and toggles it on click. Prefer it over ariaLabel when the label is on screen.
ariaDescribedBy string | nullnull Extra ids for aria-describedby , merged with the surrounding form field's hint or error.
class string'' Extra CSS classes, merged with the component's own through cn() ; yours win on conflicts.
OutputPayloadDescription
touchvoid Emits when the control loses focus, so Signal Forms marks the field touched.