<< All versions

Skill v1.0.0

currentAutomated scan100/100
jeffreytse/grimoire-core/apply-aria-live-regions
──Details
PublishedNovember 19, 2026 at 06:38 AM
Content Hashsha256:9612374a05f5e86b...
Git SHA7ff5861b0083
──Files
Files (1 file, 6.6 KB)
SKILL.md6.6 KBactive
SKILL.md · 157 lines · 6.6 KB

name: apply-aria-live-regions description: Use when adding dynamic content that changes without a user-triggered focus move — toast notifications, search results loading, form submission status, chat messages, or any async UI update — so screen reader users are informed of the change. source: W3C WCAG 2.1 SC 4.1.3 Status Messages (Level AA); WAI-ARIA 1.2 live region specification; MDN ARIA live regions guide; Deque University ARIA live regions training tags: [accessibility, wcag, a11y, aria-live, live-regions, dynamic-content, screen-reader, developer] related: [apply-aria-roles, apply-accessible-forms, design-accessibility-standards] metadata: version: "1.0.0"


Apply ARIA Live Regions

Announce dynamic content changes to screen readers using aria-live regions or semantic live region roles — without moving focus.

Why This Is Best Practice

Adopted by: WCAG 2.1 SC 4.1.3 (Level AA) is required by Section 508 (US), EU EN 301 549, and UK PSBAR 2018. WAI-ARIA 1.2 live region support is implemented in all major screen readers (NVDA, JAWS, VoiceOver, TalkBack) since 2018. All major front-end frameworks (React, Angular, Vue) have accessibility guidance on live regions for dynamic content. Impact: Deque Systems research found that missing live region announcements are the

#2 source of screen reader usability failures in single-page applications, after focus management. A screen reader user who submits a form and hears nothing cannot know if the submission succeeded, failed, or is loading — without a live region announcement, they must explore the page manually to find out. Why best: The alternative — moving focus to the new content — is disruptive for minor status updates (toast notifications, inline search suggestions). Live regions allow content to be announced without stealing focus, preserving the user's context and interaction flow.

Sources: W3C WCAG 2.1 SC 4.1.3 (2018); WAI-ARIA 1.2 Live Region specification; Deque University; MDN ARIA live regions

Steps

Step 1: Choose the right live region role for the urgency level

Role / attributeUrgencyInterrupts?Use for
role="status" / aria-live="polite"LowNo — waits for user to finishSuccess messages, loading complete, search result count
role="alert" / aria-live="assertive"HighYes — announces immediatelyErrors, warnings, time-sensitive messages
role="log"LowNoChat history, activity feeds
role="timer"LowNoCountdown timers
aria-live="off"NoneNoDisable announcements on a region

Use polite by default. Only use assertive for critical errors or urgent warnings — interrupting a screen reader user mid-sentence is disruptive.

Step 2: Place the live region in the DOM before content is injected

html
<!-- Wrong — role="alert" added dynamically; browser may not register it -->
<script>
const el = document.createElement('div');
el.setAttribute('role', 'alert');
el.textContent = 'Error: invalid email';
document.body.appendChild(el);
</script>
<!-- Right — live region exists in DOM at page load; content is injected later -->
<div role="status" id="toast-region" aria-live="polite" aria-atomic="true"></div>
<script>
document.getElementById('toast-region').textContent = 'Profile saved successfully';
</script>

The live region container must be present in the DOM before the announcement. Dynamically creating the element and adding content simultaneously is unreliable.

Step 3: Use aria-atomic to control how changes are announced

html
<!-- aria-atomic="true" — entire region announced when any part changes -->
<div role="status" aria-live="polite" aria-atomic="true">
Showing 24 of 847 results
</div>
<!-- aria-atomic="false" (default) — only changed parts announced -->
<div role="log" aria-live="polite" aria-atomic="false">
<!-- Individual messages appended; each appended message announced -->
<p>Alice joined the chat</p>
<p>Bob sent a message</p>
</div>

For status messages with a single changing value (result count, progress), use aria-atomic="true". For append-only logs (chat, notifications), use the default aria-atomic="false".

Step 4: Common live region patterns

Toast notification:

html
<div id="toast" role="status" aria-live="polite" aria-atomic="true"
class="toast" hidden></div>
<script>
function showToast(message) {
const toast = document.getElementById('toast');
toast.textContent = ''; // clear first to re-trigger announcement
toast.removeAttribute('hidden');
requestAnimationFrame(() => { // allow DOM update before setting content
toast.textContent = message;
});
setTimeout(() => toast.setAttribute('hidden', ''), 4000);
}
showToast('Your order has been placed.');
</script>

Loading state:

html
<div role="status" aria-live="polite" id="loading-status"></div>
<script>
function setLoading(isLoading) {
const status = document.getElementById('loading-status');
status.textContent = isLoading ? 'Loading results…' : 'Results loaded';
}
</script>

Search result count:

html
<p role="status" aria-live="polite" aria-atomic="true" id="result-count"></p>
<script>
function updateResultCount(count) {
document.getElementById('result-count').textContent =
count === 0 ? 'No results found' : `${count} results found`;
}
</script>

Step 5: Test announcements with a real screen reader

  • Enable NVDA (Windows) or VoiceOver (macOS/iOS)
  • Trigger the dynamic update
  • Verify the announcement is made without focus moving
  • Verify assertive announcements interrupt current speech
  • Verify polite announcements wait for a speech pause

When NOT to Use

  • Content that takes focus anyway — if the user action opens a modal or navigates to a new page, focus management handles the announcement. No live region needed.
  • Every change in the DOM — overusing aria-live creates announcement noise. Only announce changes users need to know about without actively exploring the page.

Common Mistakes

Adding `role="alert"` to an element and content simultaneously. Some screen readers don't catch this. Pre-render the live region; inject content after.

Using `aria-live="assertive"` for non-urgent messages. Assertive interrupts whatever the screen reader is saying. Use polite for success messages, counts, loading states.

Clearing live region content immediately. If you clear and refill the region in the same tick, some screen readers announce nothing. Use requestAnimationFrame or a brief setTimeout between clear and fill.

All versions