Developer notes
- Root:
[data-a11y-server-error-bridge] - Optional form region:
[data-a11y-server-error-bridge-form-errors] - Initialization:
createServerErrorBridge(form) - Assets:
dist/index.jsanddist/styles.css
Example 01 ยท Basic
A minimal account form receives one field error and one form-level message. The bridge links the error, marks the field invalid, manages focus, and clears the field state on edit.
Scenario
The application owns submission and gives the rejected response to the bridge.
Implementation
[data-a11y-server-error-bridge][data-a11y-server-error-bridge-form-errors]createServerErrorBridge(form)dist/index.js and dist/styles.cssaria-errormessage.Copy path
applyErrors(); call clearErrors() after success or reset.<link rel="stylesheet" href="../../dist/styles.css">
<form id="account-form" data-a11y-server-error-bridge>
<div data-a11y-server-error-bridge-form-errors></div>
<label for="email">Email address</label>
<input id="email" name="email" type="email">
<button type="submit">Create account</button>
</form>import { createServerErrorBridge } from "../../dist/index.js";
const form = document.querySelector("#account-form");
const bridge = createServerErrorBridge(form);
// Use the rejected payload returned by your application.
bridge.applyErrors({
fields: { email: "An account already uses this email." },
form: ["The account could not be created."]
});