datui
Color scheme

Forms

Switch

On/off toggle.

import { Switch } from "datui";

Playground

<Switch aria-label="Notifications" />

Examples

States

Accessibility

  • Radix Switch: role="switch" with aria-checked; Space and Enter toggle.
  • Label it with <label htmlFor> or aria-label.
  • readOnly sets aria-readonly and ignores toggles.

API

Switch

On/off toggle (Radix Switch, `role="switch"`). Space and Enter toggle. Needs a label.

PropTypeDefaultDescription
checkedboolean—
classNamestring—
defaultCheckedboolean—
namestring—
onCheckedChange((checked: boolean) => void)—
readOnlyboolean—Focusable and announced, but toggling is blocked.
requiredboolean—
valuestring—