Movatterモバイル変換


[0]ホーム

URL:


Skip to content
🚀 Influence MUI's 2026 roadmap! Take our latest Developer Survey
+

Switch

Switches toggle the state of a single setting on or off.

Switches are the preferred way to adjust settings on mobile.The option that the switch controls, as well as the state it's in,should be made clear from the corresponding inline label.

PressEnter to start editing

Label

You can provide a label to theSwitch thanks to theFormControlLabel component.

PressEnter to start editing

Size

Use thesize prop to change the size of the switch.

PressEnter to start editing
PressEnter to start editing

Controlled

You can control the switch with thechecked andonChange props:

PressEnter to start editing

Switches with FormGroup

FormGroup is a helpful wrapper used to group selection controls components that provides an easier API.However, you are encouraged to useCheckboxes instead if multiple related controls are required. (See:When to use).

Assign responsibility

Be careful

Customization

Here are some examples of customizing the component.You can learn more about this in theoverrides documentation page.

Off

On

🎨 If you are looking for inspiration, you can checkMUI Treasury's customization examples.

Label placement

You can change the placement of the label:

Label placement

When to use

Accessibility

  • All form controls should have labels, and this includes radio buttons, checkboxes, and switches. In most cases, this is done by using the<label> element (FormControlLabel).
  • When a label can't be used, it's necessary to add an attribute directly to the input component.In this case, you can apply the additional attribute (for examplearia-label,aria-labelledby,title) via theinputProps prop.
<Switchvalue="checkedA"inputProps={{'aria-label':'Switch A'}}/>

API

See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.


[8]ページ先頭

©2009-2026 Movatter.jp