@rmwc/switch
TypeScript icon, indicating that this package has built-in type declarations

14.3.5 • Public • Published

Switches

On/off switches toggle the state of a single settings option. The option that the switch controls, as well as the state it’s in, should be made clear from the corresponding inline label. Switches take on the same visual properties of the radio button.

Switches are identical in function to the Checkbox component, they just present a different UI / UX paradigm.

<Switch defaultChecked label="Pizza" />
function Example() {
  const [checked, setChecked] = React.useState(false);

  return (
    <Switch
      checked={checked}
      onClick={(evt) => setChecked((c) => !c)}
      label="Cookies"
    />
  );
}
<Switch>Icecream</Switch>
<>
  <Switch disabled label="Disabled" />
  <Switch disabled defaultChecked label="Disabled" />
</>

Switch

A Switch component.

Props

Name Type Description
checked boolean Toggle the control on and off.
disabled boolean Disables the control.
foundationRef Ref<MDCSwitchFoundation<>> Advanced: A reference to the MDCFoundation.
id string A DOM ID for the toggle.
inputRef Ref<HTMLInputElement<>> A reference to the native input.
label ReactNode A label for the control.
processing boolean
ripple RipplePropT Adds a ripple effect to the component
rootProps HTMLProps<any> By default, all props except className and style spread to the input. These are additional props for the root of the checkbox.
value string | number | string[] The value of the control.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
14.3.5497latest
14.0.2-alpha.71next

Version History

VersionDownloads (Last 7 Days)Published
14.3.5497
14.3.429
14.3.38
14.3.28
14.3.1246
14.3.07
14.2.97
14.2.88
14.2.78
14.2.62
14.2.55
14.2.2686
14.2.117
14.2.08
14.1.53
14.1.49
14.1.39
14.1.28
14.1.18
14.1.08
14.0.128
14.0.1131
14.0.108
14.0.98
14.0.88
14.0.78
14.0.611
14.0.58
14.0.48
14.0.38
14.0.22
14.0.12
14.0.02
14.0.2-alpha.71
14.0.2-alpha.61
14.0.2-alpha.51
14.0.2-alpha.41
14.0.2-alpha.31
14.0.2-alpha.11
14.0.2-alpha.01
14.0.1-alpha.01
14.0.0-alpha.06
8.0.81,280
8.0.72
8.0.62
8.0.57
8.0.42
8.0.3101
8.0.22
8.0.12
8.0.016
7.0.3316
7.0.27
7.0.12
7.0.07
6.1.4978
6.1.318
6.1.27
6.1.17
6.0.149
6.0.132
6.0.127
6.0.117
6.0.102
6.0.97
6.0.57
6.0.42
6.0.37
6.0.27
6.0.12
6.0.07
6.0.0-rc.46
6.0.0-rc.36
6.0.0-rc.21
6.0.0-rc.16
6.0.0-rc.01
6.0.0-alpha.166
6.0.0-alpha.156
6.0.0-alpha.146
6.0.0-alpha.136
6.0.0-alpha.121
6.0.0-alpha.111
6.0.0-alpha.71
5.7.2347
6.0.0-alpha.66
6.0.0-alpha.51
6.0.0-alpha.31
5.7.0198
5.6.043
5.5.2139
5.5.12
5.5.02
5.4.37
5.4.22
5.4.12
5.4.02
5.3.19
5.3.02
5.2.212
5.2.1471
5.2.02
5.2.0-alpha.01
5.1.82
5.1.72
5.1.62
5.1.52
5.1.42
5.1.32
5.1.22
5.1.12
5.1.02
5.0.30-rc.01
5.0.29-rc.01
5.0.28-rc.01
5.0.27-rc.01
5.0.26-rc.01
5.0.25-rc.01
5.0.24-rc.01
5.0.23-rc.01
5.0.23-alpha.01
5.0.22-alpha.01
5.0.21-alpha.01
5.0.20-alpha.01
5.0.19-alpha.01
5.0.18-alpha.01
5.0.17-alpha.01
5.0.16-alpha.01
5.0.15-alpha.01
5.0.14-alpha.01
5.0.13-alpha.01
5.0.12-alpha.01
5.0.11-alpha.01
5.0.8-alpha.01
5.0.7-alpha.01
5.0.6-alpha.01
5.0.5-alpha.01
5.0.4-alpha.01
5.0.3-alpha.01
5.0.2-alpha.01
5.0.1-alpha.01
5.0.0-alpha.01
4.0.618
4.0.52
4.0.42
4.0.32
4.0.22
4.0.12
4.0.02
3.0.1128
3.0.102
3.0.97
3.0.82
3.0.72
3.0.62
3.0.52
3.0.43
3.0.32
3.0.02
2.2.217
2.2.02
2.1.33
2.1.22
2.1.02
2.0.22
2.0.12
2.0.07
2.0.0-alpha.71
2.0.0-alpha.61
2.0.0-alpha.51
2.0.0-alpha.41
2.0.0-alpha.31
2.0.0-alpha.21
2.0.0-alpha.16
2.0.0-alpha.01
1.10.1-alpha.06
1.10.0-alpha.06

Package Sidebar

Install

npm i @rmwc/switch

Weekly Downloads

4,568

Version

14.3.5

License

MIT

Unpacked Size

11.3 kB

Total Files

10

Last publish

Collaborators

  • jamesmfriedman