Client component

Switch

A binary toggle with real switch semantics, for settings that apply immediately.

Import#

import { Switch } from "astralis-ui";

Usage#

Use a Switch when flipping it takes effect immediately (settings); use a Checkbox when the choice is submitted with a form. The API is the native checkbox event model: checked + onChange(e) reading e.target.checked.

Sizes, colors and states#

Props#

PropTypeDefaultDescription
checked / defaultChecked / onChangeboolean / boolean / (e) => voidNone / false / NoneControlled / uncontrolled API.
size"sm" | "md" | "lg""md"Track and thumb dimensions.
colorSchemeall 15 schemes"brand"On-state hue.
childrenReactNodeNoneLabel rendered beside the track.
invalid / disabled / readOnlybooleanfalseState flags, inherited from [Field](/docs/components/field).

Keyboard#

KeyAction
SpaceToggle

Accessibility#

Renders <input type="checkbox" role="switch"> with aria-checked, so assistive tech announces it as an on/off switch, not a checkbox.