Switch

Data input

An on/off switch with bind:checked, for a setting that applies at once. With name it submits with a form. Inside a Field it takes its id, label, description, error and disabled state from the Field; use orientation="horizontal" to put the label beside it.

import { Switch } from '@limerdev/zest';
Switch for AI tools (llms.txt)
Use for
A setting that takes effect immediately: notifications on, dark rows, show archived.
Don't
A choice that only counts when a form is submitted: use Checkbox. A Switch without a label.

Examples

Basic

A Switch applies at once.

Settings

A list of settings: label and description first, the switch at the end.

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

Switch

Prop Type Default Description
checked bindable boolean false The checked state of the switch.
disabled null | false | true false Whether the switch is disabled.
name string undefined The name of the switch used in form submission. If not provided, the hidden input will not be rendered.
onCheckedChange OnChangeFn<boolean> – A callback function called when the checked state changes.
required boolean false Whether the switch is required (for form validation).
value any undefined The value of the switch used in form submission.