Accessibility in EJ2 JavaScript Toast control
27 Jun 20245 minutes to read
The toast component has been designed with WAI-ARIA specifications in mind by applying the prompt WAI-ARIA roles, states, and properties with the keyboard support. It helps users who use assistive WAI-ARIA accessibility support, which is achieved using attributes.
It provides information about the elements in a document for assistive technology.
The toast component implements the keyboard navigation support by using the following WAI-ARIA practices and is tested in major screen readers.
The Toast component followed the accessibility guidelines and standards, including ADA, Section 508, WCAG 2.2 standards, and WCAG roles that are commonly used to evaluate accessibility.
The accessibility compliance for the Toast component is outlined below.
Accessibility Criteria | Compatibility |
---|---|
WCAG 2.2 Support | |
Section 508 Support | |
Screen Reader Support | |
Right-To-Left Support | |
Color Contrast | |
Mobile Device Support | |
Keyboard Navigation Support | Not Applicable |
Accessibility Checker Validation | |
Axe-core Accessibility Validation |
WAI-ARIA attributes
Class | Description |
---|---|
role | alert: Identifies the element as a container when alert content will be added or updated. |
ej.base.enableRipple(true);
//Initialize Toast component
var toast = new ej.notifications.Toast({
title: 'Matt sent you a friend request',
content: 'You have a new friend request yet to accept',
target: document.body,
timeOut: 0
});
//Render initialized Toast component
toast.appendTo('#element');
toast.show();
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 Toast</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript Toolbar Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div class="row"> <button class="e-btn" id="show_toast"> Show Toast</button> </div>
<div id="element"></div>
<br><br>
<div id="result"></div>
<div id="templateToast" style="display: none;color:red"> System affected by virus !!! </div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Ensuring accessibility
The Toast component’s accessibility levels are ensured through an accessibility-checker and axe-core software tools during automated testing.
The accessibility compliance of the Toast component is shown in the following sample. Open the sample in a new window to evaluate the accessibility of the Toast component with accessibility tools.