Input
BetaFormsOpen in the workshop
A single-line text field with label, hint and error, as one Field.
.xg-field > .xg-label + .xg-input + .xg-hint | .xg-error · .xg-input-group with leading icon, prefix or affix · --sm. States: :hover :focus :disabled [readonly] [aria-invalid="true"].Example and markup
Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.
Shown in reports. 60 characters max.
Enter a budget of at least $50
Markup
<div class="xg-stack" style="max-width:360px">
<div class="xg-field">
<label class="xg-label" for="cmp-name">Campaign name</label>
<input class="xg-input" id="cmp-name" placeholder="e.g. Holiday promo — CTV" aria-describedby="cmp-name-h">
<p class="xg-hint" id="cmp-name-h" style="margin:0">Shown in reports. 60 characters max.</p>
</div>
<div class="xg-field">
<label class="xg-label" for="cmp-budget">Daily budget</label>
<div class="xg-input-group">
<span class="xg-input-group__prefix">$</span>
<input class="xg-input" id="cmp-budget" inputmode="decimal" value="25" aria-invalid="true" aria-describedby="cmp-budget-e">
</div>
<p class="xg-error" id="cmp-budget-e" style="margin:0">Enter a budget of at least $50</p>
</div>
</div>States
Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.
| State | Text |
|---|---|
| Default | |
| Hover | |
| Focus | |
| Filled | |
| Error | |
| Read-only | |
| Disabled |
When to use it
Use it for
free text and numbers: campaign name, daily budget, floor price.
Not for
choosing from a known list (Select); long text (Textarea); dates (Date-range picker).
Rules
- Label above the field, always visible; placeholder is an example, never the label.
- Hint below the field says the format or the limit; the error replaces nothing and appears under the hint.
- Errors say what to do: “Enter a budget of at least $50”, not “Invalid value”.
- Units go in the prefix or affix ($, %, ms), not in the value.
- Validate on blur or on submit, never on each keystroke.
Accessibility
- <label for> on every field. Hint and error are linked by aria-describedby; invalid fields carry aria-invalid="true".
- Field border uses border-control: 3:1 against the surface.
Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.
Related
Also in Forms: Textarea, Select, Checkbox, Radio, Switch, Segmented control, Search field, Date-range picker, Form layout. Used in the patterns Onboarding and sign-up, Forms and overlays.
Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).