--- name: proximity-form-fields description: 'Use this skill when laying out a form, fixing a confusing form, or building a form layout convention for a design system. Forms are where proximity failures are most visible: ambiguous label-input pairing, sections that bleed into each other, help text that orphans from its field. Trigger when designing sign-up, sign-in, settings, profile, billing, checkout, multi-step, or any structured-input surface. Sub-aspect of `proximity`; read that first if you haven''t already.' --- # Proximity in form layout Forms are the canonical proximity case. A form with poor proximity produces ambiguous label-input pairings, orphaned help text, sections that don't read as sections, and a general feeling that the user must "decode" the layout before they can fill it in. A form with good proximity reads as a structured set of pairs and groups; the user fills it in without thought. ## The form proximity ladder Use four nested levels of spacing — each level visibly tighter than the level above it: ``` Level 1: gap-1 (4px) inside a label-input pair Level 2: gap-3 (12px) between fields in a group Level 3: gap-6 (24px) between groups within a section Level 4: gap-10 (40px) between sections ``` Each level should be at least 2× the level inside it. Don't use `gap-2` and `gap-3` for different roles — they look identical. ## The label-input pair The single most important proximity decision in a form: the **label belongs with the input it labels**. Every other proximity issue cascades from this. ### Top-aligned labels (default for vertical forms) ```html
``` The label, input, and help text are bound by tight (4px) spacing. The fields are separated by loose (24px) spacing. Pairing reads instantly. ### Inline labels (left-aligned, common in admin and settings) ```html ``` Note how the help text appears in the right column under its input — proximity binds it to the field, not to the label across the row. ### Section grouping When a form spans more than ~5 fields, group them. Sections get **distinctly larger** spacing than between fields, plus a heading. ```html ``` Three ranks of spacing (1rem within a section, 2.5rem between sections, plus the tight 0.25rem inside each field). The heading is *slightly* closer to its first field (0.25rem) than to neighbors (1rem) so it groups with what it labels. ### Required indicators A common proximity question: where does the asterisk go? Right next to the label text, with no space: ```html ``` Not: ```html * ``` The asterisk is part of the label, not a separate element. Proximity confirms. ### Inline error messages Errors should appear *below* the field they reference, with tight spacing: ```htmlPlease enter a valid email.