--- meta: title: Switch description: Switches allow the user to toggle an option on or off. layout: component --- ```html:preview Switch ``` ```jsx:react import SlSwitch from '@shoelace-style/shoelace/dist/react/switch'; const App = () => Switch; ``` :::tip This component works with standard `
` elements. Please refer to the section on [form controls](/getting-started/form-controls) to learn more about form submission and client-side validation. ::: ## Examples ### Checked Use the `checked` attribute to activate the switch. ```html:preview Checked ``` ```jsx:react import SlSwitch from '@shoelace-style/shoelace/dist/react/switch'; const App = () => Checked; ``` ### Disabled Use the `disabled` attribute to disable the switch. ```html:preview Disabled ``` ```jsx:react import SlSwitch from '@shoelace-style/shoelace/dist/react/switch'; const App = () => Disabled; ``` ### Sizes Use the `size` attribute to change a switch's size. ```html:preview Small
Medium
Large ``` ```jsx:react import SlSwitch from '@shoelace-style/shoelace/dist/react/switch'; const App = () => ( <> Small
Medium
Large ); ``` ### Help Text Add descriptive help text to a switch with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead. ```html:preview Label ``` ```jsx:react import SlSwitch from '@shoelace-style/shoelace/dist/react/checkbox'; const App = () => Label; ``` ### Custom Styles Use the available custom properties to change how the switch is styled. ```html:preview Really big ``` {% raw %} ```jsx:react import SlSwitch from '@shoelace-style/shoelace/dist/react/switch'; const App = () => ( ); ``` {% endraw %}