About this set
The five field states a real form needs, each with its message in words so the state never relies on colour alone. Error shows a red border and a message that says what to fix; the input carries aria-invalid=”true” and the plain CSS styles that attribute, so the look and the announced state cannot drift apart. Success shows a green border and a confirmation, warning an amber border and advice, and disabled a greyed field with a hint. The last field validates as you type: it stays neutral while empty, then turns red while the email address is incomplete and green once it is valid. The colours come from :invalid and :valid combined with :not(:placeholder-shown), and a few lines of script copy the state to aria-invalid and add the error to aria-describedby only while it is showing. Use the static states for server-side results and the live field where early feedback helps. The Bootstrap version uses .is-invalid, .is-valid, .invalid-feedback and .valid-feedback with its in-field icons switched off, plus a small .is-warning addition; its live field toggles those classes from the browser’s own validity.
What’s included
- Error, success, warning, disabled and live states
- Every message linked to its input with aria-describedby
- Error styling keyed to aria-invalid in the plain CSS version
- Live field stays neutral until something is typed
- Bootstrap version uses .is-invalid, .is-valid and the feedback classes
Accessibility
Each message has an id and is referenced from its input's aria-describedby, so screen readers read it with the field; the error field is marked aria-invalid, and the live field gains and loses aria-invalid and its error description as the value changes. Message text reaches 4.5:1 and state borders 3:1 against the page. The required field says (required) in its label. Focus adds a 3px ring, pink on the error field, and border transitions are removed under prefers-reduced-motion.
Customise it
In plain CSS change --f-error, --f-ok, --f-ok-text, --f-warn and --f-warn-text on .f. In Bootstrap set --bs-form-invalid-color, --bs-form-invalid-border-color, --bs-form-valid-color and --bs-form-valid-border-color on .fx; in Tailwind edit the border- and text- colour classes.






