Skip to content

UI & Design

Form States

Free

Build forms with labels, inline errors, pending submits, and no silent failure.

Difficulty foundational
Version v1.1

Purpose

Make generated forms usable with a keyboard and honest when the server rejects input.

Procedure

--- name: form-states description: Build forms with labels, inline errors, pending submits, and no silent failure. ---

Form States

Purpose

Make generated forms usable with a keyboard and honest when the server rejects input.

Procedure

Every control has a visible label associated with it (htmlFor or wrapping). Placeholder text is not the label.

Validation:

  • Check on submit, and after a field has been edited once. Do not shout errors on the first keystroke.
  • The message says what to do ("Use at least 8 characters"), not only "Invalid".
  • Connect the message to the control with aria-describedby and aria-invalid.

Submit:

  • Disable the submit control while the request is in flight and change its label to a progressive form ("Saving…").
  • Keep the values. Do not clear the form on failure.
  • Put the server's message where the user is looking, at the form or the field. Do not only log it.

Do not invent client rules that the server does not enforce. If the server is the authority, still give an immediate check for empty required fields so the user is not punished by a round trip for a blank submit.

Enter submits a single-purpose form. It must not submit a destructive form accidentally. Destructive confirms are a separate explicit step.

Example requests

1. Account form

Request: Apply Form States to the profile form. Validate the name and show server errors. Expected: Associated labels, disabled submit while pending, and an error tied to the field.

Dependencies

None. Work in the repository that is already open. Do not add packages unless the procedure names one.

Compatibility

This document follows the Agent Skills layout (a folder named form-states containing SKILL.md). Claude Code, Cursor, Codex, and Gemini CLI can load that file from the paths in the Skilling installation guide. GitHub Copilot does not load SKILL.md. Use the Copilot instructions copy, and narrow applyTo before you commit it.

Example prompts

Account form

Apply Form States to the profile form. Validate the name and show server errors.

Expected: Associated labels, disabled submit while pending, and an error tied to the field.

Choose the agent

This skill is installed for one agent at a time. Pick the section you are using.

Related

  • Contrast Pairs

    Pick text and background pairs that meet WCAG AA, and never encode meaning with color alone.

  • Interface Craft

    Design a screen around one job, one primary action, and the empty, loading, and error states before any decoration.

  • Schema Contracts

    Validate input at the server boundary and return a stable error shape.

Reviews

No reviews yet.

    Sign in to review.

    Report a problem

    Inaccurate steps, an unsafe instruction, or a licensing concern.

    Sign in to report.