Skip to content
SENVENLI UI

Switch

Turns a setting on or off immediately.
A setting
import { Switch } from "@senvenli/react/selection";

Examples

Saved by the app

Controlled, with a description that reports the state.

Disabled

A setting that cannot change, on and off.

Sizes

`size` small, medium (default) or large.

Guidelines

When to use it

  • A setting that applies at once.

Use something else when

  • The choice is submitted with a form. Checkbox

Do and avoid

  • Name the setting by its on-state ("Online orders"), never "On/Off".

Accessibility

Keyboard

KeysWhat happens
SpaceToggles it.

Built in

  • Announced as a switch with its state; a busy state while saving.

You provide

  • A label naming the setting.

API reference

Switch

size
ComponentSize

small, medium (default) or large; the provider default otherwise.

childrenRequired
React.ReactNode

The setting, named as its on-state ("Online orders"), never "On/Off".

isSelected
boolean
defaultSelected
boolean
onChange
(isSelected: boolean) => void
description
React.ReactNode
isDisabled
boolean
name
string
aria-busy
boolean | "true" | "false"

Marks a pending change ("saving"): aria-busy on the switch control itself, the role="switch" input, where screen readers read it. It does not lock the switch: it still toggles unless isDisabled is set too. Left out, the DOM is unchanged. It is applied after hydration (in a layout effect, as React Aria does not forward it), so server-rendered HTML does not carry it; it appears on the first client render.