Native Validation Cues
Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 19 of 55.
HTML constraints such as required, type="email" and numeric min/max determine native validity. Tailwind invalid: styles a control while those constraints are not satisfied. CSS does not define or submit the validation rule.
<label for="seats">Seats, from 2 to 8</label><input id="seats" type="number" min="2" max="8" required class="border invalid:border-4">This example immediately gives an invalid required number a thicker border. An empty required control is invalid even before interaction, so this timing is deliberate. Other interfaces may delay error presentation, but this lesson practices the immediate native state.
Keep visible instructions and labels alongside the visual cue. When a user corrects or clears a value, the selector updates automatically. A zero-width base outline with an invalid override provides a cue without changing the control’s layout dimensions.
Challenge
MediumUse immediate native validity styling on the required contact email. Show a solid 2px outline whenever it is invalid, including when empty; use zero outline width when valid. Preserve the required email constraint, label and visible instruction. The outline must return if the field is cleared.
Preserve the supplied content, semantic elements and IDs. Edit the requested utility classes. Press Run preview after edits, then Check/Run code to grade the result. Supplied JavaScript is read-only.
Try it yourself
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<form><label for="email">Contact email</label><input id="email" type="email" required class="border p-2 outline-solid outline-0"><p>Enter a complete email address.</p></form>
</body></html>
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Responsive UI Patterns
1Page Shells
Growing Page ShellsFlexible Content RailsBounded Scroll RegionsFull-Bleed RegionsRecap: Page Shells4Form Layouts
Responsive Field GroupsFocused Field GroupsSelectable Form OptionsNative Validation CuesRecap: Form Layouts2Navigation Patterns
Wrapping NavigationCurrent Page CuesNative Menu DisclosuresKeyboard Skip LinksRecap: Navigation5Data Tables
Scrollable Data TablesPredictable Table ColumnsRow State PresentationSticky Table HeadersRecap: Data Tables8Interactive Panels
Expanded Control CuesChoice Card StatesFocus-Aware Help PanelsContent-Aware Empty StatesRecap: Interactive Panels11Project: Event Portal
Portal ShellSession Browser