Skip to content

Latest commit

 

History

History
43 lines (26 loc) · 1.81 KB

aria-live.md

File metadata and controls

43 lines (26 loc) · 1.81 KB

Let's discuss the aria-live attribute.

aria-live

The aria-live attribute is used to define the live region behavior for screen readers. It informs assistive technologies that content within the specified region may change dynamically and should be announced to the user.

Example:

<div aria-live="polite">
  The status will be announced dynamically here.
</div>

In this example, the content within the <div> with aria-live="polite" will be announced by screen readers when it changes. The "polite" value indicates that the update is not urgent and won't interrupt the screen reader's current activity.

Values:

  • "off": The default value. Indicates that the live region should not be automatically announced.

  • "polite": Indicates that changes in the live region are not critical; they will be announced when the screen reader is idle.

  • "assertive": Indicates that changes in the live region are important and should be announced immediately, possibly interrupting the screen reader.

Best Practices:

  1. Use aria-live on regions that are dynamically updated to ensure screen reader users are informed of changes.

  2. Choose the appropriate value ("off," "polite," or "assertive") based on the urgency of the content changes.

  3. Avoid placing aria-live on large or frequently changing sections, as it may lead to too much information being announced.

Use Case:

Consider a chat application where new messages dynamically appear. You might use aria-live to ensure that screen reader users are informed of incoming messages:

<div aria-live="polite" class="chat-messages">
  <!-- New chat messages dynamically added here -->
</div>

This ensures that screen reader users are notified of new messages as they arrive without interrupting their current interaction.