Use cases
Section titled “Use cases”Make sure the Switch is suitable for your use case. There may be other, more appropriate components available.
| Use case | Checkbox | Radio | Switch | ToggleButton |
|---|---|---|---|---|
| Confirm an input for a form submission | ✅ | ❌ | ❌ | ❌ |
| Select a single option from multiple choices for a form submission | ❌ | ✅ | ❌ | ❌ |
| Make an instantaneous, binary choice (switch a setting on or off) | ❌ | ❌ | ✅ | ❌ |
| Toggle an option within a toolbar | ❌ | ❌ | ❌ | ✅ |
StrataKit MUI modifications
Section titled “StrataKit MUI modifications”- The
colorprop is not supported. Color is determined automatically based on state (e.g., checked, disabled). - Restyled using StrataKit’s visual language.
- Includes full
forced-colorssupport.
Examples
Section titled “Examples”Checked
Section titled “Checked”Use the defaultChecked prop to set the initial checked state. Alternatively, use the checked and onChange props to control the checked state.
- Small: Use in compact interfaces where space is limited.
- Medium: Default size, suitable for most use cases.
- Use a clear, descriptive label for each Switch.
- Use a Switch when the effect is instantaneous (no confirmation or submission is required).
🚫 Don’t
Section titled “🚫 Don’t”- Don’t use switches for mandatory actions. The checked state of a switch can never be invalid.
- Don’t use one switch to change multiple settings simultaneously.
- Don’t use switches inside a form that needs submission. Use Checkbox instead.