Skip to main content

MCDS


Switch

A toggle switch component for binary on/off states.

Code

<Switch
  id="dark-mode"
  name="theme-toggle"
  label="Dark Mode"
  checked={false}
/>

Props

Name Type Required Description
label string Yes Label text for the switch
id string Yes Unique identifier for the switch input
name string Yes Name attribute for the switch input
checked boolean No Whether the switch is checked by default
Default: false

Usage

Do’s

  • Use for binary settings (on or off) that take immediate effect
  • Provide clear, concise labels

Don’t’s

  • Don’t use for actions that require confirmation
  • Don’t use for multiple options (use radio buttons instead)
  • Don’t use for settings that don’t take immediate effect
  • Don’t use for destructive actions

Accessibility

Keyboard Navigation

Screen Reader Support