form-design
Form Design
Forms are where users give the product data. Every unnecessary obstacle between the user and a completed form is a failure. The design goal is to make correct input easy and incorrect input obvious — before the user submits.
The Three Guidance Layers
Each layer serves a distinct purpose. Do not collapse them.
Layer 1 — Helper Text
Explains what to enter. Appears below the input, always visible, in small secondary text.
Email address
[ ]
Use the email you signed up with.
- Write in plain language from the user's perspective
- Keep it to one sentence — if you need more, the field is too complex or misnamed
- Do not repeat the label ("Enter your email" below a label that says "Email" is redundant)
- Helper text is not a replacement for a label — the label is still required
Layer 2 — Placeholder
Shows the format or an example value. Appears inside the input, disappears on typing.
[jane@example.com ]
- Use a realistic example, not a description:
+358 40 123 4567notEnter phone number - Never use placeholder as a label — it disappears and leaves the user without context
- Keep it grey (
--color-text-secondary) and lighter than actual input text - Optional — not every field needs a placeholder
Layer 3 — Validation
Confirms whether the input is correct. The most important layer.
Email address
[jane@ ] ← invalid
✗ Enter a valid email address.
Validation timing:
- On blur (leaving the field): default for most fields — validates once the user has finished
- Real-time (on input): use when the format is complex or the error is likely — password strength, IBAN, VAT number, URL, regex-heavy fields
- On submit: catches anything missed, scrolls to the first error
Real-time validation must be forgiving at the start — do not show an error the instant the user starts typing. Show it after a short debounce (300–500ms) or after the first character that makes the input definitively wrong.
Submit Button State
The submit button enables when the form is valid. This is one of the clearest affordance signals in form design — the user sees the goal and knows when they have reached it.
[Submit] ← disabled, low contrast, cursor: not-allowed
(fields incomplete or invalid)
[Submit] ← enabled, full colour, cursor: pointer
(all required fields valid)
Implementation:
<button type="submit" disabled={!isFormValid}>Submit</button>
For long or complex forms where real-time validation is not practical, do not disable the submit — validate on submit and scroll to errors instead. Disabled submit on a long form frustrates users who cannot tell what is missing.
Loading state on submit: Replace label with spinner, disable the button. Prevent double-submission.
Field Anatomy
[Label] [Optional badge if optional]
[Input field ]
[Helper text — what to enter, format, constraints ]
[Error message — appears below helper text on validation fail ]
<div class="field">
<label for="vat">VAT number <span class="optional">Optional</span></label>
<input
id="vat"
type="text"
placeholder="FI12345678"
aria-describedby="vat-helper vat-error"
aria-invalid="true"
>
<p id="vat-helper" class="helper-text">Finnish VAT numbers start with FI followed by 8 digits.</p>
<p id="vat-error" class="error-text" role="alert">Enter a valid Finnish VAT number (e.g. FI12345678).</p>
</div>
Required vs Optional
Mark the minority. If most fields are required, mark the optional ones. If most are optional, mark the required ones.
- Do not rely on colour alone — add a text label ("Required" or asterisk with legend)
- Place the required/optional indicator in the label, not only in the placeholder or helper text
<label>Email <abbr title="Required">*</abbr></label>
<!-- or -->
<label>Phone <span class="badge">Optional</span></label>
Grouping with Fieldset
Related fields belong in a <fieldset> with a <legend>. This is semantic HTML and helps screen readers announce the group context.
<fieldset>
<legend>Billing address</legend>
<label>Street</label><input type="text">
<label>City</label><input type="text">
<label>Postal code</label><input type="text">
</fieldset>
Use fieldsets for:
- Address groups
- Payment details
- Radio button groups
- Checkbox groups
Input Types
Use the correct type — browsers provide free validation, appropriate keyboards, and autofill.
| Data | Input type |
|---|---|
type="email" |
|
| Phone | type="tel" |
| URL | type="url" |
| Number | type="number" |
| Password | type="password" |
| Date | type="date" |
| Search | type="search" |
| Colour | type="color" |
On mobile, type="email" shows the email keyboard, type="tel" shows the numpad. These are free UX improvements.
Autofill Support
Allow browsers to autofill. Do not disable it unless there is a security requirement.
<input type="text" autocomplete="name">
<input type="email" autocomplete="email">
<input type="tel" autocomplete="tel">
<input type="text" autocomplete="street-address">
<input type="text" autocomplete="postal-code">
<input type="text" autocomplete="cc-number"> <!-- credit card -->
<input type="password" autocomplete="new-password">
Correct autocomplete values reduce friction dramatically for returning users and on mobile.
Review Checklist
- Every field has a visible label (not just placeholder)
- Helper text is below the input and explains what to enter
- Placeholder shows format or example, not a description
- Validation triggers on blur for simple fields, real-time for complex ones
- Error message is adjacent to the field that failed
- Error message is associated via
aria-describedby - Required/optional marked on the minority of fields
- Submit button is disabled when form is invalid (for short forms)
- Submit button shows a loading state and prevents re-submission
- Related fields are grouped in
<fieldset>with<legend> - Correct
typeattribute on all inputs -
autocompleteattributes set on address, contact, and payment fields
More from dembrandt/dembrandt-skills
nielsen-usability-heuristics
UI design and review should apply Nielsen's 10 Usability Heuristics — the foundational principles for evaluating and improving usability. Use when auditing an interface, designing interaction flows, writing error messages, or reviewing any UI for usability issues.
45color-mode-and-theme
Choose light, dark, or combined color mode deliberately based on brand tone and user context. Offer a theme selector only when user control genuinely matters — enterprise tools, data-heavy UIs, or extended-use applications. Use when defining the base color palette, designing a design system, or deciding whether to build dark mode support.
43generate-ui-from-brand
Pipeline skill — turns a URL or DESIGN.md into a concrete UI structure with decisions already made. Extracts live design tokens, normalizes them into a semantic system, applies UX principles, and outputs an actionable UI spec. Use when building UI for an existing brand from scratch, auditing a design system, or refactoring visual inconsistency.
42scroll-areas
Scroll areas inside a layout should be avoided wherever possible. When unavoidable, allow only one scroll axis at a time and always keep the user in control. Use when designing layouts, data tables, panels, or any component that might introduce an inner scroll container.
42micro-interactions
Micro-interactions are small, purposeful animations and responses that reward the user and make the interface feel alive — an animated icon, a satisfying toggle, a subtle reveal. Borrowed from the natural world, they add delight without distraction. Use when designing interactive components, success states, toggles, loaders, or any moment worth celebrating.
42elevation-and-depth
Elevation — subtle shadows and layering — communicates visual hierarchy by lifting elements above the surface. Combined with border-radius, it creates the tactile quality of cards, modals, and interactive surfaces. Use when designing cards, dropdowns, modals, tooltips, or any floating UI element.
42