Switch
The Switch component toggles the state of a single setting on or off. It is used independently or as a form component within a Form Block.
Properties
Name | Type | Default | Description |
---|---|---|---|
name | string | Specifies the name of the component (form component only). | |
label | node | Specifies a label for the component. | |
value | any | Specifies a value for the component. | |
checked | bool | false | If true, the switch is checked. |
required | bool | false | Indicates if the switch must be set. |
disabled | bool | false | If true, the switch is disabled. |
autofocus | bool | false | If true, autofocus is enabled. |
Style Attributes
Name | Type | Default | Description |
---|---|---|---|
color | default primary secondary error info success warning string | primary | Defines the color of the component. |
size | small medium string | medium | Defines the size of the component. |
labelPlacement | top bottom start end string | end | Specifies the location of the switch label. |
disableRipple | bool | false | By default, the switch component has a ripple effect triggered when the switch state is modified. To disable this effect, set "Disable Ripple" on. |
Subcomponents
The Switch component has a subcomponent that allows an icon to replace the normal thumb on the switch.
Icon
Checked Icon - specifies an icon to use when the switch is set.
Unchecked Icon - specifies an icon to use when the switch is not set.
For further details, see the Icon component.
Properties
Name | Type | Default | Description |
---|---|---|---|
color | inherit primary secondary action disabled error string | inherit | Defines the color of the icon. |
size | inherit small medium large string | small | Defines the size of the icon. |
viewBox | 0 0 24 24 | Defines the size of the view box that displays the icon. | |
fill | hex #ffffff rgb 5,5,5 | The fill color of the icon. | |
stroke | hex #ffffff rgb 5,5,5 | The stroke color of the icon. |
For more detail on the Switch component, see the MUI developer docs.