Latitude ComponentsLibrary 0.1.0

Radio

Chooses exactly one option from a short list. Put the options, <lat-radio>, in a<lat-radio-group>: the group holds the value, and the arrow keys move between options. For two to five views or modes, use a segmented control. Rules: UX Elements & Rules → Radio (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-radio/0.1.0/lat-radio.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-radio/0.1.0/lat-radio.js (1.9 KB gzipped)
SHA-2564c59928be74f7f74bfea193e29bd873b2e819dfed7d6d26f2f4c800667e9b5d8

This file defines both <lat-radio> and <lat-radio-group>.

Permutations

A group

Dark
All viewers Panel only Invited people
Light
All viewers Panel only Invited people
<lat-radio-group label="Who can watch" value="all">
  <lat-radio value="all">All viewers</lat-radio>
  <lat-radio value="panel">Panel only</lat-radio>
  <lat-radio value="invited">Invited people</lat-radio>
</lat-radio-group>

Horizontal, nothing selected yet

Dark
Auto 720p 1080p
Light
Auto 720p 1080p
<lat-radio-group label="Video quality" orientation="horizontal">
  <lat-radio value="auto">Auto</lat-radio>
  <lat-radio value="720">720p</lat-radio>
  <lat-radio value="1080">1080p</lat-radio>
</lat-radio-group>

A disabled option

Dark
Your own audience Latitude panel (upgrade needed)
Light
Your own audience Latitude panel (upgrade needed)
<lat-radio-group label="Recruitment" value="own">
  <lat-radio value="own">Your own audience</lat-radio>
  <lat-radio value="panel" disabled>Latitude panel (upgrade needed)</lat-radio>
</lat-radio-group>

Disabled group

Dark
English Spanish
Light
English Spanish
<lat-radio-group label="Language" value="en" disabled>
  <lat-radio value="en">English</lat-radio>
  <lat-radio value="es">Spanish</lat-radio>
</lat-radio-group>

In a form

Dark
Newest first Video time
Apply Reset
Light
Newest first Video time
Apply Reset
<form style="display: flex; flex-direction: column; align-items: flex-start; gap: 8px"
  onsubmit="event.preventDefault();
    this.querySelector('output').value = new URLSearchParams(new FormData(this))">
  <lat-radio-group name="sort" label="Sort comments by" required>
    <lat-radio value="newest">Newest first</lat-radio>
    <lat-radio value="time">Video time</lat-radio>
  </lat-radio-group>
  <div style="display: flex; align-items: center; gap: 16px">
    <lat-button type="submit" size="sm">Apply</lat-button>
    <lat-button type="reset" size="sm" variant="ghost">Reset</lat-button>
    <output></output>
  </div>
</form>

Attributes

<lat-radio-group>

AttributeValuesNotes
valuetextThe chosen option's value; empty when none is chosen. Its value when the page loads is what a form reset restores.
labeltextThe group's name for screen readers (or use aria-labelledby).
nametextSubmitted as name=value.
requiredbooleanThe form won't submit until an option is chosen.
orientationvertical (default), horizontal
disabledbooleanDisables every option. Also follows a disabled <fieldset>.

<lat-radio>

AttributeValuesNotes
valuetextThe group's value when this option is chosen.
checkedbooleanSet by the group. In markup, another way to choose the starting option.
disabledbooleanCan't be chosen; the arrow keys skip it.
labeltextThe name for screen readers when there's no visible text.

Events

EventOnWhen
change<lat-radio-group>The user chooses an option, by pointer or arrow key. Read value on the group.