Validation

Set it from the server or HTMX; the CSS derives the focus color in oklch automatically.

Validation is attribute-driven: aria-invalid="true" turns the border to $color-danger with the --forma-icon-invalid-true icon, aria-invalid="false" turns it to $color-success with its icon. On focus, the border deepens in oklch automatically. Since it is a plain attribute, you can set it from the server, from HTMX responses or from a tiny script: no validation library needed.

The attribute doubles as screen-reader semantics, the state colors adapt to dark mode via light-dark(), and focus feedback is derived in CSS, so there is nothing to maintain in JavaScript.

Border colors follow --forma-border-color (set from $color-success/$color-danger) and the icons follow --forma-icon-invalid-true/false, so both can be swapped per project or per element in a style attribute.

Validation states

Set the attribute from the server, from HTMX responses or from a tiny script: the border recolors, the icon swaps, and the state doubles as screen-reader semantics. Colors adapt to dark mode via light-dark().

HTML
<form>
  <label>
    Email
    <input type="email" value="pau@example.com" aria-invalid="false">
  </label>
  <label>
    Email
    <input type="email" value="not-an-email" aria-invalid="true">
  </label>
</form>