Skip to content
+

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';
Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the native component are also available.

checked

className

defaultChecked

disabled

onChange

readOnly

required

slotProps

slots


The ref is forwarded to the root element.

Slots

To learn how to customize the slot, check out the Overriding component structure guide.

root

input

thumb

track

CSS classes

These class names are useful for styling with CSS. They are applied to the root slot when specific states are triggered.

.Mui-checkedSTATE

.Mui-disabledSTATE

.Mui-focusVisibleSTATE

.Mui-readOnlySTATE