Live Region
`pura-live-region` is a managed ARIA live announcer, hidden by default (sr-only), that delivers out-of-band status messages using the clear-and-rewrite technique so that every call is actually picked up by assistive technology. Use it for dynamic feedback (saving, errors, progress) without trapping focus. The machine-readable layer is the centerpiece: it reflects role=status, aria-live, and stable data-* attributes on the host in light DOM, and keeps a global registry `window.__puraLiveRegions` (with history and `query(id)`/`latest()` helpers), letting agents read the latest announcement of each region without a screen reader.
Preview
<div style="display:flex;flex-direction:column;gap:12px;align-items:flex-start">
<button id="btn-salvar">Save changes</button>
<pura-live-region id="status" live="polite" visible label="Form status">Ready to save.</pura-live-region>
</div>
<script type="module">
import "/pura/lib/live-region.js";
const regiao = document.getElementById("status");
let n = 0;
document.getElementById("btn-salvar").addEventListener("click", () => {
n++;
regiao.announce(`Changes saved successfully (${n}).`);
});
</script> Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
live | "polite" | "assertive" | polite | Politeness level of the announcement, reflected in aria-live. Any invalid value falls back to polite. |
visible | boolean | false | Opt-in escape hatch: renders the announced text visibly (useful for authoring/debugging). By default the region is sr-only. |
label | string | — | Optional aria-label applied to the region host. |
Installation
pura is copy-paste and dependency-free. Load the whole library, or just this component.
<link rel="stylesheet" href="/pura/tokens.css">
<script type="module" src="/pura/lib/live-region.js"></script> import "./pura/lib/live-region.js";