Comments (3)
I, too, think this is something that has some space for improvement. tabindex
and :focus
sound like a really good starting point for this.
from 30-seconds-of-css.
There are actually quite a few caveats with accurately conveying a "popout menu" component to screen readers, let alone sighted keyboard users, that just can not be done with CSS alone.
- A
button
should really be the element that is the trigger for such a component. If going the route of using adiv
and adding atabindex
, an ARIArole="button"
would need to be set to thediv
and JavaScript would need to listen for keypress of space or enter for keyboard press. Which brings me to point 2... - Focusing on the trigger alone would be insufficient for the component, as when focus was removed from the trigger, the revealed content would become hidden again. The component can continue to use
:hover
for mouse users, but should have JavaScript allowing the trigger to be pressed/toggle the state of the popout container. e.g.<div class="reference"> <!-- JS would control the state of the button, toggling between true/false for the aria-expanded attribute. This could be utilized as the CSS selector to effectively show/hide the popout-menu --> <button type="button" aria-expanded="true/false" aria-controls="pop_menu"> Trigger Name </button> <div id="pop_menu" class="popout-menu"> ... </div> </div>
button[aria-expanded="false"] + .popout-menu { visibility: hidden; } button[aria-expanded="true"] + .popout-menu { visibility: visible; }
- Do not allow focus of content within the popout menu if the popout menu is not purposefully opened. This is not a present behavior, but more of a preemptive warning, in case one was thinking they might be able to circumvent the previous requirements by utilizing
:focus-within
to mitigate the fact the popout content would disappear once focus left the trigger. Mouse users have the luxury of scanning a page and hovering over / revealing content they want to, while ignoring the rest. Keyboard users (sighted or not) typically must traverse the DOM sequentially. Coming to an element that should allow them the ability to show/hide related content, they should have the same choice as mouse users as to whether they want to engage with that content or not. Forcing them to engage with the hidden content, regardless of their preference, is a poor user experience.
If you made it this far, I appreciate you reading my short primer on the accessibility considerations for components such as this :)
from 30-seconds-of-css.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from 30-seconds-of-css.
Related Issues (20)
- [FEATURE] Multiline truncation HOT 2
- how to build this? HOT 19
- [BUG] Animation / Button Border Animation not clickable HOT 4
- [QUESTION] Used color scheme? HOT 2
- PWA feature HOT 3
- Chinese translation HOT 8
- Sorry, I am coming again. HOT 1
- Reinstate old UI and website link HOT 30
- [BUG] offscreen snippet links to scetchy/phising website HOT 1
- Scam site linked in one of the snippets HOT 1
- Change the selection color HOT 2
- [Enhancement] Fix typo in about section on the html page HOT 1
- A (hopefully) better Hamburger Button HOT 2
- Adding More Snippets for CSS HOT 5
- Add side effect note for the css rules HOT 2
- The preview image in "Image Rotate on Hover" is broken. HOT 2
- Is 30-seconds-of-css not participating in Hacktoberfest? HOT 2
- CSS Neumorphic Buttons HOT 2
- CSS : Neumorphic Buttons HOT 2
- Website horizontal scroll (CSS issue) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 30-seconds-of-css.