--- layout: layouts/component.njk title: Switch description: A control that allows the user to toggle between checked and not checked. toc: - label: Usage id: usage - label: Examples id: examples children: - label: Form id: example-form --- {% from "macros/code_preview.njk" import code_preview %} {% from "macros/code_block.njk" import code_block %} {% set code %}{% endset %} {{ code_preview("switch", code) }}
You can style a <input type="checkbox"> element as a switch by adding a role="switch" attribute, and adding the input class or having a parent with the form class (read more about form).