Skip to main content

Switch

import { Switch } from "@study/ui"

Result
Loading...
Live Editor
function Example() {
  const [on, setOn] = useState(true);
  return (
    <div style={{ maxWidth: 420 }}>
      <Switch label="Reminders by email" description="One day before every deadline." checked={on} onChange={(e) => setOn(e.target.checked)} />
    </div>
  );
}

Variants and states​

Light

Dark

When to use​

✓ DoTakes effect at once, without saving.
✗ Don'tIn a form with a save button – there it is a Checkbox.

Props​

PropTypeDefaultMeaning
label *ReactNode–
descriptionReactNode–
refRef<HTMLInputElement>–

Accessibility​

  • A checkbox with role="switch": screen readers say "on" or "off".
  • Green means on – and the knob is on the right. Both together, not the colour alone.