0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
The <form-field>web component wraps a label, input, and optional help/error text into a single accessible unit. It wires aria-describedby from the control to its hint and error <output> elements for you (authors no longer need to write it by hand), shows validation state, and adds required indicators. See the form-field page for its full API.
form-field with hint and error outputs
12345678
<formclass="stacked"><form-field><labelfor="email">Email</label><inputtype="email"id="email"name="email"required /><outputclass="hint"for="email">We'll never share your email.</output><outputclass="error"for="email"aria-live="polite"></output></form-field></form>
Form Actions
Use <footer class="actions"> for the submit/cancel button row at the bottom of a form. The .end modifier right-aligns buttons; .between pushes groups apart.
Form actions patterns
1234567891011121314151617181920
<!-- End-aligned (most common) --><formclass="stacked"> ...fields...<footerclass="actions end"><buttontype="button"class="secondary">Cancel</button><buttontype="submit">Submit</button></footer></form><!-- Space between (delete + save) --><formclass="stacked"> ...fields...<footerclass="actions between"><buttontype="button"class="ghost">Delete</button><span><buttontype="button"class="secondary">Cancel</button><buttontype="submit">Save</button></span></footer></form>
Class
Alignment
.actions
Start-aligned (default)
.actions.end
End-aligned
.actions.between
Space between groups
Help and Error Text
Inside a <form-field>, use <output class="hint"> for persistent help and an empty <output class="error"> for validation messages. <form-field> fills the error output (from data-message-* or the browser message), toggles aria-invalid, and wires both outputs into the control’s aria-describedby.
Hint and error outputs
1234567
<form-field><labelfor="password">Password</label><inputtype="password"id="password"name="password"minlength="8"requireddata-message-tooshort="Use at least 8 characters." /><outputclass="hint"for="password">At least 8 characters.</output><outputclass="error"for="password"aria-live="polite"></output></form-field>
Outside <form-field> (small static forms, server-rendered errors), <p class="help"> and <p class="error"> are styled inside a form; connect them yourself with aria-describedby and set aria-invalid="true" on the control.
Validation and Submission (data-validate)
Add data-validate to a <form> to let the form coordinator own validation UI. It sets novalidate (no browser bubbles), validates every <form-field> on submit, runs cross-field (data-match) and checkbox-group (data-min-checked/data-max-checked) checks, marks invalid bare controls with aria-invalid="true", and then either focuses the error summary or the first invalid control. Without JavaScript the form still submits with native validation.
Error summary
Author a summary region inside the form. On an invalid submit it is un-hidden, filled with one link per error (radio groups appear once; checkbox groups link their first box; messages match what the field shows) and focused. After that it updates when a field loses focus or changes — never per keystroke — and only when the set of errors changes. Once every error is fixed it collapses and gets hidden again, so stale links are neither focusable nor announced.
Authored error summary
12345678
<formdata-validateaction="/contact"method="post"><sectiondata-form-summaryrole="alert"tabindex="-1"hidden><h2data-summary-heading>There are problems with your submission</h2><uldata-summary-list></ul></section> ...fields...<buttontype="submit">Send</button></form>
An element with data-summary-heading is rewritten with a count (“Please fix 2 errors:”); omit the attribute to keep your own heading. The older <output class="error-summary" role="alert" tabindex="-1"> pattern is still filled the same way. data-validate="summary" hides the inline field errors and shows only the summary.
Submit modes (data-submit)
Value
After validation passes
absent / native
Submits natively with requestSubmit(submitter), so the clicked button’s name/value, formaction and formmethod apply.
event
Dispatches a cancelable, bubbling vb:submit event whose detail is the FormData (including the submitter). Nothing is sent.
fetch
Sends with fetch(). Method is the submitter’s formmethod, else the form’s methodattribute, else POST; GET builds a query string. URL honours formaction. Sets data-submitting while in flight, then data-success or data-error.
Events
vb:beforesubmit — cancelable, bubbling, fires after validation passes and before any mode runs; detail is { form, submitter }. Cancel it to stop the submission (bot protection, confirmation).
vb:submit — data-submit="event" only; detail is the FormData.
Fetch results
Success:data-success on the form hides everything except [data-form-success], which is shown and focused (it gets tabindex="-1" and role="status" if you did not set them).
Server field errors: a non-OK JSON response with { "errors": { "fieldName": "message" } } puts each message on its field (via form-field’s setError()) and in the summary — always as text, never HTML.
Network error:data-error="network" on the form and the [data-form-error] element is shown. Author one (with role="alert") to control the copy and placement; otherwise a <p data-form-error role="alert"> is created at the top of the form.
The next submit clears data-success/data-error and re-hides those elements.
Fetch form with status elements
12345678
<formdata-validatedata-submit="fetch"action="/api/contact"method="post"><pdata-form-errorrole="alert"hidden>We could not send your message. Try again.</p> ...fields...<buttontype="submit"data-loading="Sending...">Send</button><sectiondata-form-successrole="status"tabindex="-1"hidden><p>Thank you! Your message has been sent.</p></section></form>
Loading buttons (data-loading)
A submit button with data-loading shows a spinner and aria-busy only once a submission actually proceeds: an invalid submit, a cancelled vb:beforesubmit or any preventDefault() on the native submit leaves it alone. In fetch mode it reverts when data-submitting is cleared; in event mode clear it yourself with delete button.dataset.loadingActive when your handler finishes (or let data-loading-timeout, default 10 s, revert it).
Translating built-in text
Every string the coordinator writes can be overridden on the <form> (fieldset- and field-level attributes win where noted).
“Select at least {min}” / “Select no more than {max}” (also on the fieldset)
data-message-match
“Values do not match” (also on the field)
data-label-group / data-message-invalid-selection
“Group” / “Invalid selection” — fallbacks for a fieldset entry without a legend or message
data-message-network
“Something went wrong. Please try again.” (generated [data-form-error] only)
Complete Contact Form
A full example combining form.stacked, <form-field>, <fieldset>, and <footer class="actions">.
Conditional Fields (data-show-when)
Use data-show-when or data-hide-when on any element inside a form to conditionally display sections based on another field’s value. Hidden sections get hidden and inert, and their controls are disabled — so a hidden required field never blocks submit and its value is not sent. Showing the section re-enables only the controls it disabled; anything you marked disabled yourself stays disabled. See data-show-when for the full condition syntax, checkbox groups and reset behaviour.
Hide a section when a condition is met — the inverse of data-show-when.
Hide when checkbox checked
123456789
<label><inputtype="checkbox"name="gift"value="yes"> This is a gift</label><form-fielddata-hide-when="gift=yes"><labelfor="receipt">Send receipt to</label><inputtype="email"id="receipt"name="receipt"></form-field>
Works with <select>, <input type="radio">, <input type="checkbox">, and text inputs. The name refers to the nameattribute of the controlling field within the same <form>.
Form Autosave (data-autosave)
Add data-autosave="key" to a <form> to automatically save its data to localStorage as the user types. On page reload, the draft is restored and a “Draft restored” toast appears. Drafts are cleared on submit or reset and expire after 24 hours. Passwords, hidden inputs, buttons, card numbers and one-time codes are never stored. Full reference, including what is stored: data-autosave.
Storage key for this form’s draft. Must be unique per form.
Behavior
Save: Debounced (500ms) on every input and change event
Restore: On page load if a non-expired draft exists
Clear: On form submit or reset
Skip: Password, hidden and file inputs, buttons, autocomplete="off", card and one-time-code fields, and anything marked data-autosave-ignore are never saved or restored
Expire: Drafts older than 24 hours are discarded
Multi-step Forms (data-wizard)
form[data-wizard] splits a form into fieldset[data-wizard-step] steps with a <progress data-wizard-progress> bar and a nav[data-wizard-nav] of previous/next/submit buttons. Without JavaScript every step shows and the form submits normally. The data-wizard page documents every option (conditional steps, persistence, history, <progress-tracker>); the wizard pattern shows a full flow.
The visible “Step 2 of 4” counter is decorative (step changes are announced through a visually hidden status region). Translate its words with custom properties:
Localising the wizard step counter
1234
form[data-wizard]:lang(fr) {--wizard-label-step: "Étape ";--wizard-label-of: " sur ";}
Accessibility Notes
Label all inputs: Every form control needs an associated label
Use fieldsets: Group related fields with fieldset and legend
Error identification: Invalid controls carry aria-invalid="true" and point at their message with aria-describedby — <form-field> and data-validate do this for you; wire it by hand only for bare controls in unenhanced forms
Error summary: For long forms, add a [data-form-summary] so keyboard and screen reader users land on a list of links to every error
Autocomplete: Add appropriate autocomplete attributes for autofill
Focus management: Use autofocus on the first field (one per page)
Submit button: Always include a visible submit button, not just Enter key handling
Status changes: Fetch success moves focus to [data-form-success] (a role="status" region); network failures use a role="alert"[data-form-error] element, not CSS-generated text