Skip to main content

Switch

Examples

Check out the Usage section for details about how to design a switch properly, and the different configuration options we provide.

Basic example

A switch is a component that a user can use to change between an on and off state.

<Switch label="Switch" />

OnChange example

You can set a callback function to run when a user changes a switch's state.

<Switch
label="Switch"
OnChange={(event, value) =>
console.log('Switch toggled. The value is now', value)
}
/>