Latitude ComponentsLibrary 0.1.0

Input

A single-line text field for short free text: names, titles, search terms, times. Give every field a label; show it above the field unless the context already names it. Errors sit under the field and say how to fix it. Rules: UX Elements & Rules → Input (R-I2, R-I4).

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-input/0.1.0/lat-input.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-input/0.1.0/lat-input.js (1.8 KB gzipped)
SHA-25632d1ef6dc959ac4711709e740ef2f26446757509c18f6e3cf8d5708b013fdf2c

A leading icon goes in the icon slot, usually as a <lat-icon>, so load that file too.

Permutations

Label above, empty and filled

Dark
Light
<lat-input label="Study name" placeholder="Q3 brand lift"></lat-input>
<lat-input label="Study name" value="Q3 brand lift"></lat-input>

Leading icon, label not shown

Dark
Light
<lat-input label="Search studies" hide-label type="search"
  placeholder="Search studies">
  <lat-icon slot="icon" name="search"></lat-icon>
</lat-input>
<lat-input label="Start time" hide-label value="00:42">
  <lat-icon slot="icon" name="clock"></lat-icon>
</lat-input>

Error

Dark
Light
<lat-input label="Email" type="email" value="sam@"
  error="Enter an email address, like name@company.com"></lat-input>

Disabled

Dark
Light
<lat-input label="Study name" value="Q3 brand lift" disabled></lat-input>
<lat-input label="Study name" placeholder="Q3 brand lift" disabled></lat-input>

Required, in a form

Dark
Reset Save
Light
Reset Save
<form
  style="display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px"
  onsubmit="event.preventDefault();
    this.querySelector('output').value = 'Saved'">
  <lat-input label="Study name" name="study" required
    placeholder="Q3 brand lift"></lat-input>
  <lat-button type="reset">Reset</lat-button>
  <lat-button variant="primary" type="submit">Save</lat-button>
  <output></output>
</form>

Attributes

AttributeValuesNotes
labeltextThe field's name, shown above it. Always set it.
hide-labelbooleanKeeps the label for screen readers without showing it, when the context already names the field.
placeholdertextAn example of what to type; never instead of a label.
valuetextThe initial value. The value property holds the current one; resetting the form puts this back.
nametextSubmitted with the form.
typetext (default), email, password, search, tel, url
errortextShows the message under the field in the error style, marks the field invalid and blocks submitting until cleared. Say how to fix it.
required, minlength, maxlength, patternChecked like a native input. After a failed submit, the browser's message shows under the field until the value changes.
disabled, readonlybooleanA disabled fieldset disables the field too.
autocompletetextPassed to the native input.

Slots and events

NameNotes
icon slotA leading icon, shown at 20px in the text color.
input eventOn every edit.
change eventWhen an edit is committed: on leaving the field or pressing Enter.

Enter submits the form the field is in, as on a native input.