Checkbox
Turns an option on or off, alone or within a group. Use it where the choice is saved with the rest of a form; for a setting that takes effect at once, use a switch. Rules: UX Elements & Rules → Checkbox (R-S3: rows at least 32px tall, label right of a 24px 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-checkbox/0.1.0/lat-checkbox.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-checkbox/0.1.0/lat-checkbox.js (1.6 KB gzipped) |
| SHA-256 | 69c57af036ac8d1eca15b97a8c188182ec41c9025a8f65818b148ebd6ff74123 |
Permutations
Unchecked and checked
DarkInclude comments
Include ratings
LightInclude comments
Include ratings
<lat-checkbox>Include comments</lat-checkbox>
<lat-checkbox checked>Include ratings</lat-checkbox>Disabled
DarkInclude transcripts
Include reactions
LightInclude transcripts
Include reactions
<lat-checkbox disabled>Include transcripts</lat-checkbox>
<lat-checkbox disabled checked>Include reactions</lat-checkbox>In a list
Dark
Positive
Neutral
Negative
Light
Positive
Neutral
Negative
<div style="display: flex; flex-direction: column">
<lat-checkbox checked>Positive</lat-checkbox>
<lat-checkbox checked>Neutral</lat-checkbox>
<lat-checkbox>Negative</lat-checkbox>
</div>Without visible text
Dark
Light
<lat-checkbox label="Select Product launch teaser"></lat-checkbox>
<lat-checkbox label="Select Holiday campaign cut" checked></lat-checkbox>In a form
Dark
Light
<form style="display: flex; flex-wrap: wrap; align-items: center; gap: 16px"
onsubmit="event.preventDefault();
this.querySelector('output').value = new URLSearchParams(new FormData(this))">
<lat-checkbox name="export" value="comments" checked>Include comments</lat-checkbox>
<lat-checkbox name="export" value="ratings">Include ratings</lat-checkbox>
<lat-checkbox name="terms" required>I've read the export terms</lat-checkbox>
<lat-button type="submit" size="sm">Export</lat-button>
<lat-button type="reset" size="sm" variant="ghost">Reset</lat-button>
<output></output>
</form>Attributes
| Attribute | Values | Notes |
|---|---|---|
checked | boolean | Its value when the page loads is what a form reset restores. |
name, value | text | Submitted as name=value while checked. value defaults to on. |
required | boolean | The form won't submit until it's checked. |
disabled | boolean | Also follows a disabled <fieldset>. |
label | text | The name for screen readers when there's no visible text, as in a table row. |
Events
| Event | When |
|---|---|
change | The user checks or unchecks it. Read checked on the element. |
input | Same moment as change, as with a native checkbox. |