Accessibility in React Drop down button component
30 Jan 20235 minutes to read
ARIA attributes
The web accessibility makes web content and web applications more accessible for people with disabilities.
It especially helps in dynamic content change and development of advanced user interface controls
with AJAX, HTML, JavaScript, and related technologies. DropDownButton provides built-in compliance
with WAI-ARIA
specifications.WAI-ARIA
support is achieved through the attributes like
aria-expanded
, aria-owns
and aria-haspopup
applied for action item in DropDownButton.
It helps the people with disabilities by providing information about the widget for assistive
technology in the screen readers. DropDownButton component contains the menu
role and menuItem
role.
Properties | Functionality |
---|---|
menu | This role will be specified for an DropDownButton element. |
menuItem | This role will be specified for an action items. |
aria-haspopup | Indicates the availability and type of interactive dropdown popup element. |
aria-expanded | Indicates whether the dropdown popup can be expanded or collapsed, as well as indicates whether its current state is expanded or collapsed. |
aria-owns | Identifies an elements in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship. |
Keyboard interaction
Keyboard shortcuts | Actions |
Esc | Closes the opened popup. |
Enter | Opens the popup, or activates the highlighted item and closes the popup. |
Space | Opens the popup. |
Up | Navigates up or to the previous action item. |
Down | Navigates down or to the next action item. |
Alt + Up Arrow | Closes the popup. |
Alt + Down Arrow | Opens the popup |
import { enableRipple } from '@syncfusion/ej2-base';
import { DropDownButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
// To render DropDownButton.
function App() {
let items = [
{
text: 'Cut',
iconCss: 'e-db-icons e-cut'
},
{
text: 'Copy',
iconCss: 'e-icons e-copy'
},
{
text: 'Paste',
iconCss: 'e-db-icons e-paste'
},
{
separator: true
},
{
text: 'Font',
iconCss: 'e-db-icons e-font'
},
{
text: 'Paragraph',
iconCss: 'e-db-icons e-paragraph'
}
];
return (<div>
<DropDownButtonComponent items={items} iconCss='e-icons e-edit'> Edit </DropDownButtonComponent>
</div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('button'));
import { enableRipple } from '@syncfusion/ej2-base';
import { DropDownButtonComponent, ItemModel } from '@syncfusion/ej2-react-splitbuttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
// To render DropDownButton.
function App() {
let items: ItemModel[] = [
{
text: 'Cut',
iconCss: 'e-db-icons e-cut'
},
{
text: 'Copy',
iconCss: 'e-icons e-copy'
},
{
text: 'Paste',
iconCss: 'e-db-icons e-paste'
},
{
separator: true
},
{
text: 'Font',
iconCss: 'e-db-icons e-font'
},
{
text: 'Paragraph',
iconCss: 'e-db-icons e-paragraph'
}];
return (
<div>
<DropDownButtonComponent items = {items} iconCss= 'e-icons e-edit'> Edit </DropDownButtonComponent>
</div>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('button'));