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.
| Version | 0.1.0 |
|---|---|
| File | /components/lat-radio/0.1.0/lat-radio.js (1.9 KB gzipped) |
| SHA-256 | 4c59928be74f7f74bfea193e29bd873b2e819dfed7d6d26f2f4c800667e9b5d8 |
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
Light
<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>
| Attribute | Values | Notes |
|---|---|---|
value | text | The chosen option's value; empty when none is chosen. Its value when the page loads is what a form reset restores. |
label | text | The group's name for screen readers (or use aria-labelledby). |
name | text | Submitted as name=value. |
required | boolean | The form won't submit until an option is chosen. |
orientation | vertical (default), horizontal | |
disabled | boolean | Disables every option. Also follows a disabled <fieldset>. |
<lat-radio>
| Attribute | Values | Notes |
|---|---|---|
value | text | The group's value when this option is chosen. |
checked | boolean | Set by the group. In markup, another way to choose the starting option. |
disabled | boolean | Can't be chosen; the arrow keys skip it. |
label | text | The name for screen readers when there's no visible text. |
Events
| Event | On | When |
|---|---|---|
change | <lat-radio-group> | The user chooses an option, by pointer or arrow key. Read value on the group. |