Switch
Switches are UI elements that let users choose between two states—most commonly on/off.
Switch API
Import
import { Switch } from '@mui/base/Switch';
// or
import { Switch } from '@mui/base';Props of the native component are also available.
| Name | Type | Default | Description | 
|---|---|---|---|
| checked | bool | - | If   | 
| className | func | string  | - | Class names applied to the element or a function that returns them based on the component's state.  | 
| defaultChecked | bool | - | The default checked state. Use when the component is not controlled.  | 
| disabled | bool | false | If   | 
| inputRef | ref | - | Ref to the underlying input element.  | 
| name | string | - | Name of the underlying input element.  | 
| onChange | func | - | Callback fired when the state is changed. Signature: function(event: React.ChangeEvent
  | 
| readOnly | bool | false | If   | 
| render | func | - | A function to customize rendering of the component.  | 
| required | bool | false | If   | 
ref is forwarded to the root element.Theme default props
You can useSwitch to change the default props of this component with the theme.SwitchThumb API
Import
import { SwitchThumb } from '@mui/base/Switch';
// or
import { SwitchThumb } from '@mui/base';Props of the native component are also available.
| Name | Type | Default | Description | 
|---|---|---|---|
| className | func | string  | - | Class names applied to the element or a function that returns them based on the component's state.  | 
| render | func | - | A function to customize rendering of the component.  | 
ref is forwarded to the root element.Theme default props
You can useSwitchThumb to change the default props of this component with the theme.