Inputs

Field

A label, a control and a hint stacked as one. The error message waits until the field has been touched.

Examples

Field

Used in URLs and exports. Enter a name.

Inline field

We'll send the invite here.

Anatomy

.fieldColumn wrapper with a small gap. Add data-inline to put the label beside the control.
> labelSmall, medium-weight caption. Point its for at the control's id.
> .inputThe control: an .input, a .select, an .input-group or any other input.
> smallOptional hint in muted text. Hidden while the error shows.
> [data-error]Optional error message in the danger colour. Hidden until the control is invalid.

API

AttributeValuesDescription
data-errorbooleanOn a child of .field: the error message. Shown once the control matches :user-invalid or carries aria-invalid="true", and then it replaces the <small> hint.
data-requiredon labelbooleanAppends a danger-coloured asterisk. Pair it with required on the control; the marker alone validates nothing.
data-inlineon .fieldbooleanTwo columns: the label (at least 8rem) beside the control, with hint and error under the control.
aria-invalidtrueOn the control: shows the error message straight away, without waiting for the user. Use it for errors from the server.
requiredbooleanOn the control: native validation. The browser reports :user-invalid only after the user has edited or left the control, so an untouched form shows no errors.

Accessibility

  • Connect the label with for and id; the field's layout expects the label and the control as siblings. A placeholder is not a label.
  • The hint and error are not linked to the control by the CSS. Give them ids and list them in the control's aria-describedby so they are read with it.
  • The asterisk is generated content and may not be read. required on the control is what announces the field as required.
  • Errors revealed by :user-invalid appear silently. For errors that arrive after submit, set aria-invalid="true" and move focus to the first invalid field.
Jump to
ProportionFoundations
MaterialFoundations
PresetsFoundations
ShellLayouts · Application
Container and stacksLayouts · Pages
SplitLayouts · Pages
Grid, bento, masonryLayouts · Pages
Switcher and rowLayouts · Pages
↑↓Move↵OpenescClose