Switch component renders a pill-shaped toggle that flips a single setting on or off. It is Status: Draft and is backed by Mantine’s Switch primitive. Clementine exports it from @clementine-ds/ui with the Clementine theme applied.
When to use
- The change takes immediate effect — no Save button is required (e.g., enabling dark mode, toggling a notification preference, activating a feature flag).
- You have a single binary setting to control.
- The interface context makes “on/off” semantics self-evident.
When not to use
- Form submissions where the user sets a value and then clicks Submit — use
Checkboxinstead.Switchimplies instant effect;Checkboximplies pending form state. - Multiple related binary options shown together — consider a
Checkboxgroup to keep affordances consistent. - Mutually exclusive options from a set — use
RadioorSelect.
Usage
ImportSwitch from @clementine-ds/ui.
Uncontrolled
Controlled
With on/off inner labels
UseonLabel and offLabel to show text inside the track for added clarity.
Disabled state
Props
SwitchProps extends Mantine’s SwitchProps, which itself extends the native <input type="checkbox"> element. All standard HTML input attributes are forwarded to the underlying input.
Interaction states
The thumb animates between positions on state change. The transition completes in 200 ms or less, in line with the Clementine motion spec.
Accessibility
- The underlying element is
<input type="checkbox" role="switch">. Therole="switch"attribute communicates the on/off semantics to assistive technologies, distinct from a standard checkbox. aria-checkedis automatically managed by the browser based on thecheckedstate of the underlying input.- Always provide a
labelprop or anaria-labelattribute. An unlabeled switch is not announced usefully by screen readers.