Latitude ComponentsLibrary 0.1.0

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.

Version0.1.0
File/components/lat-checkbox/0.1.0/lat-checkbox.js (1.6 KB gzipped)
SHA-25669c57af036ac8d1eca15b97a8c188182ec41c9025a8f65818b148ebd6ff74123

Permutations

Unchecked and checked

Dark
Include comments Include ratings
Light
Include comments Include ratings
<lat-checkbox>Include comments</lat-checkbox>
<lat-checkbox checked>Include ratings</lat-checkbox>

Disabled

Dark
Include transcripts Include reactions
Light
Include 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
Include comments Include ratings I've read the export terms Export Reset
Light
Include comments Include ratings I've read the export terms Export Reset
<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

AttributeValuesNotes
checkedbooleanIts value when the page loads is what a form reset restores.
name, valuetextSubmitted as name=value while checked. value defaults to on.
requiredbooleanThe form won't submit until it's checked.
disabledbooleanAlso follows a disabled <fieldset>.
labeltextThe name for screen readers when there's no visible text, as in a table row.

Events

EventWhen
changeThe user checks or unchecks it. Read checked on the element.
inputSame moment as change, as with a native checkbox.