Skip to content

Error Text

The message shown when a field cannot be submitted as it stands. It belongs right below the field, not at the top of the page. If the text should explain what the field expects before the user has done anything, use Help Text.

data-variantUsed for
(omitted)Errors that stop submission
warningSomething looks odd, but the user may continue

Three things have to agree at the same time: data-state for the colour, aria-invalid for the screen reader, and aria-describedby for the text itself.

Field sets all three when you give it invalid. That is why that component exists.

  • Say what the user should do, not what the system objected to. “Enter the date as DD-MM-YYYY” helps where “Invalid value” does not.
  • Include an example when the format is unusual.
  • Do not blame the user, and drop the exclamation mark.
ClassWhat it is
.lt-error-textThe message. The colour comes from data-variant.

See Customising for how the layer works.

  • Show the error when the user has left the field, not while they are typing.
  • If the message appears while the page is otherwise still, put role="alert" on the element.
  • If a form is submitted with several errors, move focus to the first one that failed.
  • Never remove the message without removing aria-invalid at the same time.