There are functionally three ways to create a live region in the DOM:
- Use
aria-live="assertive"oraria-live="polite"Usingaria-liveto designate an element as a live region is the most common way to do so. In theory, the difference betweenassertiveandpoliteaffects how where notification text is inserted in the screen reader's speech queue. However, in practice this is not consistent between operating systems and screen readers. Generally usearia-live="assertive"when the notification is likely more important than a user's current interaction, and usearia-live="polite"when the notification is less important than what the user is currently doing. - Use
role="alert"Thealertapproach is best used for error messages such as form errors or high-importance toasts. Some screen readers say "alert" or a similar word before the text of the live region element. It is the only live region that consistently gets
