Switch

<wa-switch> Since 2.0 stable

Switches allow the user to toggle an option on or off.

Switch
<wa-switch>Switch</wa-switch>

This component works with standard <form> elements. Please refer to the section on form controls to learn more about form submission and client-side validation.

Examples

Checked

Use the checked attribute to activate the switch.

Checked
<wa-switch checked>Checked</wa-switch>

Disabled

Use the disabled attribute to disable the switch.

Disabled
<wa-switch disabled>Disabled</wa-switch>

Sizes

Use the size attribute to change a switch's size.

Small
Medium
Large
<wa-switch size="small">Small</wa-switch>
<br />
<wa-switch size="medium">Medium</wa-switch>
<br />
<wa-switch size="large">Large</wa-switch>

Hint

Add descriptive hint to a switch with the hint attribute. For hints that contain HTML, use the hint slot instead.

Label
<wa-switch hint="What should the user know about the switch?">Label</wa-switch>

Custom Styles

Use the available custom properties to change how the switch is styled.

Really big
<wa-switch style="--width: 80px; --height: 40px; --thumb-size: 36px;">Really big</wa-switch>

Slots

Learn more about using slots.

Attributes & Properties

Learn more about attributes and properties.

Methods

Learn more about methods.

Events

Learn more about events.

CSS custom properties

Learn more about CSS custom properties.

CSS parts

Learn more about CSS parts.

Importing

The autoloader is the recommended way to import components. If you prefer to do it manually, use one of the following code snippets.

CDN npm React

To manually import this component from the CDN, use the following code.

import 'https://early.webawesome.com/webawesome@3.0.0-beta.2/dist/components/switch/switch.js';

To manually import this component from NPM, use the following code.

import '@awesome.me/webawesome/dist/components/switch/switch.js';

To manually import this component from React, use the following code.

import '@awesome.me/webawesome/dist/react/switch';
Need a hand? Report a bug Ask for help
    No results