Skip to main content

Switch

Imports​

import {Switch} from 'material-expressive-react';
import {Switch} from 'material-expressive-react/switch';

Props​

PropTypeDefaultRequiredDescription
disabledbooleanNo
iconsbooleanNo
namestringNo
onChange((event: Event) => void)No
onInput((event: InputEvent) => void)No
requiredbooleanNo
selectedbooleanNo
showOnlySelectedIconbooleanNo
valuestringNo

Events​

  • onChange → DOM event change
  • onInput → DOM event input

Slots​

Material Web components frequently use named slots. In React, you can pass slot="..." on children (e.g. <Icon slot="icon" />).

If you need to slot a child component that does not accept a slot prop, use the Slotted utility (see Utilities → Slotted).

Examples​

See Storybook for live examples and variants.