@3mo/switch
v0.2.2
Published
A web component for labelled on/off switches, built on Material Web.
Readme
Switch
A web component for labelled on/off switches, built on Material Web.
A switch that turns a single setting on or off, with an optional label.
Installation
npm install @3mo/switchimport '@3mo/switch'Usage
<mo-switch label='Dark mode'></mo-switch>Examples
- States — On and off, each also disabled.
- Custom Properties —
--mo-switch-accent-colorcolors the switch when on,--mo-switch-unselected-colorwhen off.
API
mo-switch
Properties
| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| label | label | string | "" | The label beside the switch |
| disabled | disabled | boolean | false | Fades the switch and makes it ignore input |
| selected | selected | boolean | false | Whether the switch is on |
Events
| Name | Detail | Description |
| --- | --- | --- |
| change | boolean | Dispatched when the selection state of the switch changes. |
CSS custom properties
| Name | Description |
| --- | --- |
| --mo-switch-accent-color | The color of the handle and track when on, and of the focus ring |
| --mo-switch-unselected-color | The color of the handle and track when off |
| --mo-switch-selected-icon-color | |
Links
License
MIT © 3MO GmbH
