SwitchGroup

Related switches as one panel. A row tints while on, the header counts how many are on and flips every switch at once. Inputs.

Open playground
Notifications1 of 3 on
EmailUpdates in your inbox
PushAlerts on this device
Text messageOnly for urgent issues

About

SwitchGroup is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { SwitchGroup } from "@ashutoshswamy/smoui" and set items[].icon, items, label among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { SwitchGroup } from "@ashutoshswamy/smoui";

<SwitchGroup label="Notifications" items={[{ value: "email", label: "Email" }, { value: "push", label: "Push" }]} onChange={setChannels} />

Props 5

items[].icon

A leading icon on the row.

IconName
items

Switches in the group.

{ value: string; label: string; description?: string }[]
label

Visible group name.

string
value / defaultValue

Controlled or initial enabled values.

string[]
onChange

Called when any switch changes.

(value: string[]) => void