Switch
Turns a setting on or off immediately, with no Save step. When the choice is saved with a form, use acheckbox. Rules: UX Elements & Rules → Switch. The old Switcher is deprecated; use a segmented control.
Add it to a page
Load the pinned file once in your Latitude Site or web page, then use the tag.
<script type="module" src="https://web-components.sites.latd.com/components/lat-switch/0.1.0/lat-switch.js"></script>The file is an ES module. It loads Lit, the design-system tokens and the Roobert stylesheet from this catalog once per page, however many components you use.
| Version | 0.1.0 |
|---|---|
| File | /components/lat-switch/0.1.0/lat-switch.js (1.1 KB gzipped) |
| SHA-256 | 6963a7f0ee6a8ec198020f42ac0d1c0835f1c10d1149b6584bd8fce8dfafbcb0 |
Permutations
Off and on
DarkAutoplay next video
Show captions
LightAutoplay next video
Show captions
<lat-switch>Autoplay next video</lat-switch>
<lat-switch checked>Show captions</lat-switch>Disabled
DarkCollect emails
Anonymous viewing
LightCollect emails
Anonymous viewing
<lat-switch disabled>Collect emails</lat-switch>
<lat-switch disabled checked>Anonymous viewing</lat-switch>Without visible text
Dark
Light
<lat-switch label="Comments"></lat-switch>
<lat-switch label="Reactions" checked></lat-switch>Settings list
Dark
Comments
Reactions
One-touch rating
Light
Comments
Reactions
One-touch rating
<div style="display: flex; flex-direction: column">
<lat-switch checked>Comments</lat-switch>
<lat-switch checked>Reactions</lat-switch>
<lat-switch>One-touch rating</lat-switch>
</div>Attributes
| Attribute | Values | Notes |
|---|---|---|
checked | boolean | On. Its value when the page loads is what a form reset restores. |
name, value | text | Submitted as name=value while on. value defaults to on. |
disabled | boolean | Shown at 40% opacity. Also follows a disabled <fieldset>. |
label | text | The name for screen readers when there's no visible text. |
Events
| Event | When |
|---|---|
change | The user turns it on or off. Apply the setting now; read checked on the element. |
input | Same moment as change. |