# Large forms

Long forms split into labelled groups, in one or more columns.

_Diagram: A large form fills the content area as labelled groups of fields, in two columns on wide screens._

## Live example

### New invoice

```html
<form data-form-sections aria-labelledby="invoice-title">
  <section aria-labelledby="inv-customer-title">
    <header>
      <h3 id="inv-customer-title">Customer</h3>
      <p>Who the invoice is addressed to.</p>
    </header>
    <div>
      <div data-field>
        <label for="inv-company">Company</label>
        <input type="text" id="inv-company" name="company" value="Orbital Mechanics GmbH" autocomplete="organization">
      </div>
      <div data-field>
        <label for="inv-contact">Contact email</label>
        <input type="email" id="inv-contact" name="contact" value="accounts@orbital-mechanics.example" autocomplete="email">
      </div>
      <div data-field>
        <label for="inv-vat">VAT number</label>
        <input type="text" id="inv-vat" name="vat" value="DE 123 456 789" autocomplete="off">
      </div>
    </div>
  </section>
  <section aria-labelledby="inv-details-title">
    <header>
      <h3 id="inv-details-title">Invoice details</h3>
      <p>Dates and references printed in the invoice header.</p>
    </header>
    <div>
      <div data-field>
        <label for="inv-date">Invoice date</label>
        <input type="date" id="inv-date" name="date" value="2025-03-14">
      </div>
      <div data-field>
        <label for="inv-due">Due date</label>
        <input type="date" id="inv-due" name="due" value="2025-04-13" aria-describedby="inv-due-hint">
        <p id="inv-due-hint" data-field-hint>30 days net, from the customer's payment terms.</p>
      </div>
      <div data-field>
        <label for="inv-currency">Currency</label>
        <select id="inv-currency" name="currency">
          <option selected>EUR</option>
          <option>GBP</option>
          <option>USD</option>
        </select>
      </div>
      <div data-field>
        <label for="inv-po">Customer reference</label>
        <input type="text" id="inv-po" name="po" value="PO-OM-4471" autocomplete="off">
      </div>
    </div>
  </section>
  <section aria-labelledby="inv-address-title">
    <header>
      <h3 id="inv-address-title">Billing address</h3>
      <p>Where the paper copy goes, if one is sent.</p>
    </header>
    <div>
      <div data-field>
        <label for="inv-street">Street and number</label>
        <input type="text" id="inv-street" name="street" value="Am Fallturm 1" autocomplete="address-line1">
      </div>
      <div data-field>
        <label for="inv-postcode">Postal code</label>
        <input type="text" id="inv-postcode" name="postcode" value="28359" autocomplete="postal-code">
      </div>
      <div data-field>
        <label for="inv-city">City</label>
        <input type="text" id="inv-city" name="city" value="Bremen" autocomplete="address-level2">
      </div>
      <div data-field>
        <label for="inv-country">Country</label>
        <select id="inv-country" name="country" autocomplete="country">
          <option value="DE" selected>Germany</option>
          <option value="NL">Netherlands</option>
          <option value="GB">United Kingdom</option>
        </select>
      </div>
    </div>
  </section>
  <section aria-labelledby="inv-payment-title">
    <header>
      <h3 id="inv-payment-title">Payment</h3>
      <p>How the customer pays this invoice.</p>
    </header>
    <div>
      <fieldset>
        <legend>Payment method</legend>
        <label><input type="radio" name="method" value="transfer" checked> Bank transfer</label>
        <label><input type="radio" name="method" value="debit"> Direct debit</label>
        <label><input type="radio" name="method" value="card"> Card payment link</label>
      </fieldset>
      <div data-field>
        <label for="inv-notes">Note on the invoice</label>
        <textarea id="inv-notes" name="notes">Please quote INV-2025-0319 with your payment.</textarea>
      </div>
    </div>
  </section>
  <footer data-action-bar>
    <button type="submit">Create invoice</button>
    <a href="./" data-button="secondary">Cancel</a>
  </footer>
</form>
```

## Attributes

| Attribute or value | Where | Effect |
| --- | --- | --- |
| `data-form-sections` | the `<form>` | each child `<section>` is a section: |
| `<header>` |  | its heading (h2) and an optional description `<p>` |
| `one body element` |  | a `<div>` (or `<fieldset>`) of fields, after the header |

### Breakpoint

48rem of the form's own inline size. A container query condition cannot read a custom property, so it is written as a length.

### Keyboard

Native keyboard behavior; see [HTML `<form>` element](https://html.spec.whatwg.org/multipage/forms.html#the-form-element).

## Accessibility

- Sections keep source order in both layouts, so the reading and Tab order stay top to bottom (WCAG 1.3.2, 2.4.3).
- Put the form's buttons in a data-action-bar at the end of the form so they stay in reach.
- Nothing scrolls sideways at 320px (WCAG 1.4.10).

## Specifications

- [HTML `<form>` element](https://html.spec.whatwg.org/multipage/forms.html#the-form-element)
- [HTML `<fieldset>` element](https://html.spec.whatwg.org/multipage/form-elements.html#the-fieldset-element)
- [WAI Forms tutorial](https://www.w3.org/WAI/tutorials/forms/)
- [WCAG 3.3.2 Labels or Instructions](https://www.w3.org/WAI/WCAG22/Understanding/labels-or-instructions.html)
- [W3C grouping](https://www.w3.org/WAI/tutorials/forms/grouping/)
- [MDN Container queries](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Containment/Container_queries)

## See also

- [Organisms](https://domestic-ui.odonckers.dev/organisms/index.md)
- Source: [`css/components/organisms/large-forms.css`](https://github.com/odonckers/domestic-ui/blob/main/css/components/organisms/large-forms.css), [`examples/organisms/large-forms.html`](https://github.com/odonckers/domestic-ui/blob/main/examples/organisms/large-forms.html)
- Demos: Account settings view ([Plain HTML](https://github.com/odonckers/domestic-ui/blob/main/demos/vanilla/settings.html), [React](https://github.com/odonckers/domestic-ui/blob/main/demos/react/src/SettingsPage.tsx), [Angular](https://github.com/odonckers/domestic-ui/tree/main/demos/angular/src/app/settings), [Astro](https://github.com/odonckers/domestic-ui/blob/main/demos/astro/src/pages/settings.astro), [Vue](https://github.com/odonckers/domestic-ui/blob/main/demos/vue/src/SettingsPage.vue), [Svelte](https://github.com/odonckers/domestic-ui/blob/main/demos/svelte/src/SettingsPage.svelte))

## How other systems do it

For comparison only; these are not the standard this system follows.

- Apple Human Interface Guidelines: No equivalent
- Material Design 3: No equivalent
- Vercel Geist: No equivalent
