- Implementation
- Switch Props
Common Examples
Controlling switches
Uncontrolled switch
By default, the state of a switch is handled internally. Use thedefaultChecked prop to set the initial state.To access the current value, a React ref can be used. Make sure you understand the differences between refs and state in React.Controlled switch
Alternatively, use thechecked and onChange props to manually control the checked state.React Accessibility
- The supplied
labelprop should either be text or a component containing text. If this is not possible, then either anaria-labelshould be set or a visible label should be referenced witharia-labelledby. - If the page contains additional text needed to fully understand the purpose of the
Switch, this text should be referenced witharia-describedby.

