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.
| Version | 0.1.0 |
|---|---|
| File | /components/lat-input/0.1.0/lat-input.js (1.8 KB gzipped) |
| SHA-256 | 32d1ef6dc959ac4711709e740ef2f26446757509c18f6e3cf8d5708b013fdf2c |
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
Light
<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
| Attribute | Values | Notes |
|---|---|---|
label | text | The field's name, shown above it. Always set it. |
hide-label | boolean | Keeps the label for screen readers without showing it, when the context already names the field. |
placeholder | text | An example of what to type; never instead of a label. |
value | text | The initial value. The value property holds the current one; resetting the form puts this back. |
name | text | Submitted with the form. |
type | text (default), email, password, search, tel, url | |
error | text | Shows 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, pattern | Checked like a native input. After a failed submit, the browser's message shows under the field until the value changes. | |
disabled, readonly | boolean | A disabled fieldset disables the field too. |
autocomplete | text | Passed to the native input. |
Slots and events
| Name | Notes |
|---|---|
icon slot | A leading icon, shown at 20px in the text color. |
input event | On every edit. |
change event | When an edit is committed: on leaving the field or pressing Enter. |
Enter submits the form the field is in, as on a native input.