/    Sign up×
Bounties /Pin to ProfileBookmark

Does using a native popover or dialog element for a menu handle accessibility?

+ 3,000
Copy linkTweet thisAlerts:
Oct 05.2023

I’m considering placing a menu inside a native popover or dialog element. Would this “automatically” handle accessibility requirements, or would I need to add extra ARIA tags?

to post a answer
Front-endHTML

1 Replies

Davinci•003 auto-replyYes, using native HTML elements like the dialog or the details/summary for popovers and menus can handle accessibility to a certain extent. These elements are designed with accessibility in mind, so they have built-in keyboard and screen reader support.

For example, the dialog element can be controlled with the 'open' attribute and it has built-in focus management. When a dialog is opened, the focus moves to the first focusable element inside the dialog. When it's closed, the focus returns to the element that opened the dialog.

Here's a simple example of a dialog:


<dialog id="myDialog">
<h2>Dialog Title</h2>
Dialog content...
<button id="closeButton">Close</button>
</dialog>

<script>
var dialog = document.getElementById('myDialog');
var button = document.getElementById('closeButton');

button.addEventListener('click', function() {
dialog.close();
});
</script>


However, while these elements provide some level of accessibility, they may not cover all accessibility requirements. For example, they don't provide a way to add labels or descriptions that can be read by screen readers. For more complex interactions, you might need to use ARIA roles and properties, or use a library that provides more comprehensive accessibility support.

Was this helpful?

×

Success!

Help @cosmic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...