Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 37 ยท Projects and Practice

Project: Signup Form and Pricing Cards

Build an accessible signup form and pricing cards with Tailwind CSS: input states, validation messages, a password strength meter, plan selection with peer and has.

Forms are where users decide whether to trust your product, so they deserve care. In this project you build the signup journey of a fictional app: a plan picker made of selectable cards, then a signup form with validation styling, a password strength meter and accessible error messages. You will combine nearly everything from earlier lessons: state variants, peer, has, group, theme tokens, and small amounts of JavaScript.

Design goals

  • Every input has a visible <label>; placeholders are hints only.
  • Errors are shown in text, not only in color, and are connected to the input with aria-describedby.
  • The form works with keyboard alone, and focus is always visible.
  • Hover, focus, invalid and disabled states are all designed.
  • The layout is one column on phones and uses the space well on desktop.

Step 1: the plan picker with has-checked

Each plan is a <label> wrapping a visually hidden radio. The radio provides keyboard and screen reader behavior for free (arrow keys switch plans). The label looks like a card and reacts with has-checked:.

Step 1: selectable pricing cards

The three labels share the same long class list. In a real project this would be a loop or a component, as in Reusing Styles with Components. The shared name="plan" makes the radios a group.

Step 2: the form fields

A field is a label, an input and a message area. The input styling covers five states: default, hover, focus, invalid and disabled. The message element has an id, referenced by aria-describedby, so a screen reader reads the error when the field is focused.

Validation uses the browser's built-in constraint API (required, type="email", minlength) plus user-invalid: styling, which only shows after the user interacts. A small script writes the message text.

Step 2: the signup form with validation and strength meter

There is a lot to unpack.

  • @utility field is a custom utility from Custom Utilities and Variants. The long input style is written once as a real utility, using :user-invalid and theme variables. You could also put the same classes in a template component; both are valid.
  • novalidate plus the Constraint API: the browser still computes validity, but we control when and how messages appear, avoiding the browser's default bubbles.
  • aria-live="polite" on the message paragraphs makes screen readers announce errors as they appear.
  • The strength meter is decorative (aria-hidden) and the text next to it carries the information. Its colors come from a lookup table of complete class names.
  • On a failed submit, focus moves to the first invalid field, which is the single most helpful thing a form can do for keyboard users.

Client-side validation is a convenience, not security. A real server must validate every field again, and a strength meter written like this one is a nudge, not a password policy.

Putting the pieces together

Combine Step 1 and Step 2 in one page: the plan picker on top, the form below, and the chosen plan sent in the form data. Because the radios already have name="plan", they submit along with the rest.

A good layout for large screens is two columns: grid gap-8 lg:grid-cols-[1fr_28rem], with the plan picker on the left and the form on the right. On phones it stays one column, which keeps the order logical: choose, then sign up.

Polish checklist

  • Autofill: set the right autocomplete values (name, email, new-password) so browsers and password managers help.
  • Mobile keyboards: type="email", inputmode="numeric" for codes.
  • Prevent double submits: disable the button and show a spinner (see Keyframe Animations).
  • Dark mode: pair each color with a dark: version, or use the semantic variables from Multiple Themes with CSS Variables.
  • Error summary: for long forms, add a list of problems at the top that links to each field.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why use a visually hidden radio inside each plan label?

    The real input stays in the accessibility tree, and has-checked: styles the surrounding card.
  2. 2. What does aria-describedby do on an input?

    It links the field to the element holding the hint or error message.
  3. 3. Why use user-invalid: for error borders?

    invalid: matches from the first paint; user-invalid: waits for interaction.
  4. 4. What should happen on a failed submit for the best keyboard experience?

    Focusing the first problem lets users fix it immediately without searching.

Summary

  • Build selectable cards from hidden native radios and has-checked:; keep focus visible with has-focus-visible:.
  • Connect fields, hints and errors with labels, aria-describedby and aria-live messages.
  • Style all five input states; use user-invalid: so errors appear only after interaction.
  • Drive dynamic styles (such as a strength meter) from lookup tables of complete class names.
  • Validate again on the server, and move focus to the first error on a failed submit.

Next: Practice, Mistakes and Cheat Sheet