Build / Atoms
Switch
An immediate on/off toggle.
Use a Switch when the change applies straight away (for example, "Discoverable
by email"). If the value only takes effect on submit, use a Checkbox.
Built on input[type="checkbox"] with role="switch", so it keeps native
keyboard and form behaviour while announcing as a switch.
import { Switch } from '@meetcard/deck'Stories
Source
const Default = () => <Switch label="Discoverable by email" onChange={fn()} />;On.
Source
const On = () => <Switch label="Discoverable by email" onChange={fn()} defaultChecked />;Use a Switch when the change applies immediately. If it only takes effect on submit, use a Checkbox instead.
Source
const WithDescription = () => <Switch
label="Discoverable by email"
onChange={fn()}
description="People who already have your email can find your card instantly." />;Disabled while off.
Source
const Disabled = () => <Switch label="Discoverable by email" onChange={fn()} disabled />;Disabled while on — the setting is in effect but managed elsewhere.
Source
const DisabledOn = () => <Switch label="Discoverable by email" onChange={fn()} disabled defaultChecked />;Props
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | ReactNode | — | — |
description | ReactNode | — | — |
Also accepts everything from Omit, so id, data-* and event handlers pass straight through.