Accessibility
Screen reader only
Using EuiScreenReaderOnly hides the wrapped element from the page, but keeps it accessible for screen readers to provide more context. It should be used primarily to mask text and requires the child to be a single React element for cloning.
WebAIM recommendation for screen reader-only content
"In most cases, if content (particularly content that provides functionality or interactivity) is important enough to provide to screen reader users, it should probably be made available to all users." Learn more about invisible content
Using a screen reader, verify that there is a second paragraph.
Showing on focus
If the wrapped element is focusable, you must use the showOnFocus prop to visibly show the element to all users when focused.
Tab through the following example with your keyboard to verify the element is visible on focus.
Screen reader live region
Using EuiScreenReaderLive to announce dynamic content, such as status changes based on user interaction.
The configurable role and aria-live props default to status and polite respectively for non-intrusive but timely update announcements. When not using the default values, be sure to follow ARIA guidelines for role to aria-live mapping.
Also consider other live region guidelines, such as that live regions must be present on initial page load, and should not be in a conditional JSX wrapper.
Auto-focusing the live region on text change
The focusRegionOnTextChange prop will automatically focus the EuiScreenReaderLive region (causing screen readers to read out the text content) whenever children changes.
This is primarily useful for announcing navigation or page changes, when programmatically resetting focus location back to a certain part of the page (where the EuiScreenReaderLive is placed) is desired.
Using a screen reader, click the following navigation links and notice that when the new page is announced, focus is also set to the top of the body content.
Live announcer region Beta
EuiLiveAnnouncer is a new, experimental alternative to EuiScreenReaderLive for screen reader live region announcements.
Its API and behavior may change based on feedback and testing.
Both EuiLiveAnnouncer and EuiScreenReaderLive are designed for the same use cases: to announce dynamic content, such as nodifications or status changes based on user interaction.
The main drawback for live regions is that they must be present on initial page load before reading content updates. EuiLiveAnnouncer addresses this
by updating the content after the initial render to ensure an announcement is made when mounting a component.
Same as for EuiScreenReaderLive, EuiLiveAnnouncer supports configurable role and aria-live props which default to status and polite respectively for non-intrusive but timely update announcements.
If you're not using the default values, be sure to follow ARIA guidelines for role to aria-live mapping.
Main difference
EuiLiveAnnouncerwill announce the message when the component mounts (e.g., when it first appears in the DOM), as well as when the message changes.EuiScreenReaderLivewill only announce when the message changes, and will not announce the initial message on mount.
This means EuiLiveAnnouncer is especially useful for scenarios where you want to ensure an announcement is made immediately when a component is mounted, e.g. showing a notification or alert based on user interaction.
An additional difference is that EuiLiveAnnouncer can clear its message after a configurable timeout via clearAfterMs, which prevents stale
announcements and duplicated DOM content for screen reader users. Screen readers will continue reading the message even if it was already cleared.
Key differences between EuiLiveAnnouncer and EuiScreenReaderLive
Feature | EuiLiveAnnouncer | EuiScreenReaderLive |
|---|---|---|
Auto-clear message | Yes, after configurable timeout ( clearAfterMs) | No |
Announce on mount | Yes | No |
Announce on message change | Yes | Yes |
Focus on message change | No | Yes ( focusRegionOnTextChange prop) |
Handles rapid updates | Yes | Yes |
Output consistency | High | Medium |
API stability | Beta/experimental | Stable |
Skip link
The EuiSkipLink component allows users to bypass navigation, or ornamental elements, and quickly reach the main content of the page. It requires a destinationId which should match the id of your main content. If your ID does not correspond to a valid element, the skip link will fall back to focusing the <main> tag on your page, if it exists.
Tab through the following section to verify the Skip to content button is visible on focus.