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) => void— / false / —Controlled / uncontrolled API.
size"sm" | "md" | "lg""md"Track and thumb dimensions.
colorSchemeall 11 schemes"brand"On-state hue.
childrenReactNodeLabel rendered beside the track.
invalid / disabled / readOnlybooleanfalseState flags — inherited from 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.