Patterns
Forms
People enter and change data in long and short forms. They need to see what is required, which values they cannot change, which options belong together, and find and fix every error quickly, with or without a screen reader.
Reference build
Live, built only from system components. Switch the width: the build uses its own breakpoints.
Rules
- Wrap the fields in Form with a label; express every rule as an attribute (required, type, minLength, pattern). Form keeps to the reading width; don't stretch fields across a wide screen.
- Order fields as people think about the subject, not as the database stores it. More than about six fields: split them into groups, each with a Heading.
- Several yes/no options under one question go in a CheckboxGroup; one choice out of two to five in a RadioGroup.
- A value people may see but not change stays in the form as Input readOnly, with a hint that says who changes it.
- Mark optional fields with optional; don't mark required ones. Put the hint above the control, so it is read before typing.
- Validate on submit, not while typing. Form marks every invalid field, announces a summary and focuses the first error.
- Error texts say how to fix the problem, e.g. “Enter an email address in the format name@example.com.” Errors use the terracotta accent; status red is for failed system states.
- One form, one submit button, named by what it does (“Save profile”). Areas that save on their own are separate Forms.
- Confirm success with successMessage (placeholder screens) or the server action's result.
Layout and states
What every build of this pattern must hold to. The check runs the required states on the reference build.
- One column: fields stacked with gap-stack-relaxed, submit last; groups apart by gap-group. Next to a summary use Columns main-aside with the form first.
- Fields are full width at every size up to the reading width; a summary column goes below the form under the Columns break.
| State | Proves |
|---|---|
| errors-after-empty-submit | Submitting empty marks every required field, announces a summary and moves focus to the first one. |
| invalid-format | A value in the wrong format gets its own message, not the empty-field one. Only when the form has a field with a format: email, URL, number or pattern. |
Code
import { Button, Checkbox, CheckboxGroup, Form, Input, Select, Textarea } from "@/ds";
export function Example() {
return (
<Form
label="Project request"
invalidMessage="Some fields need your attention."
successMessage="Thanks. We reply within two working days."
>
<Input label="Name" name="name" autoComplete="name" required />
<Input label="Email" name="email" type="email" autoComplete="email" required />
<Select
label="Project type"
name="type"
placeholder="Choose a project type"
required
options={[
{ value: "research", label: "UX research" },
{ value: "design", label: "Product design" },
{ value: "system", label: "Design system" },
]}
/>
<Textarea label="What should we know?" name="brief" hint="Goals, timeline, team. A few sentences are enough." optional />
<CheckboxGroup
label="Reply by"
name="reply"
optional
options={[
{ value: "email", label: "Email" },
{ value: "phone", label: "Phone call" },
]}
/>
<Checkbox label="I agree that my details are used to answer this request." name="consent" required />
<div>
<Button type="submit" variant="primary">
Send request
</Button>
</div>
</Form>
);
}Built from
Seen in: Portfolio contact flow (S1), CRM dossier forms (S3); round 5 account-settings and request-detail (2026-11-13).