Accessible hamburger buttons without JavaScript(pausly.app) |
Accessible hamburger buttons without JavaScript(pausly.app) |
The details element.
<details>
<summary>Menu</summary>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/thing">Thing</a></li>
</ul>
</details>
You may want to add a tiny bit of CSS, like adding a border, and setting the cursor to a pointer, for your sighted users: details {
padding: 0.5em;
border-style: solid;
border-width: 1px;
border-radius: 0.25em;
cursor: pointer;
}Hopefully this will change soon. I’ll amend the article when this will be the case.
Which says JavaScript is required and simplest solution for building this menu. It also states to try to avoid them when possible.
https://adrianroselli.com/2019/04/details-summary-are-not-in...
Now, I found details,& I keep the main page visible all times in a div, & then horizontal accordion styles as Details underneath it for History, Logs & other stuff e.g. https://spa.bydav.in/odo.html (type foo in the box to see page)
"Last Few Decades"? Eh? A decade.. perhaps?
"Every User Immediately"? This is not at all my experience. Perhaps with younger users, but I've seen plenty of people younger than I even stumble over sites where the nav was hidden behind a hamburger menu icon.
This sounds like it was written by someone very much in their own bubble
For screen reader users only, this provides them with the information that activating this link will open or close a menu.
Screen reader users do not need to open or close menus. Menus do not take up space or sit in front of other content. Closing a menu offers no usability benefit to a screen reader user.
All they need is the options to be present under a navigable heading that they can skip to when they need to access those options.
Meanwhile, non screen reader users are forced to guess what will be behind the ≡ button this time.
https://adrianroselli.com/2019/04/details-summary-are-not-in...
Anchors navigate. Buttons have effects.
<a href="#something"><button>menu</button></a>
Or maybe: <form action="#something"><button type="submit">menu</button></form>
Not sure either of those options are better than the original post though :)In my experience in many cases, just showing all of the menu items when JS is disabled is an easier, safer solution with cleaner markup and no hacks. After JS is detected, toggle a class on the document to hide the menu, build your button, insert it into the DOM. Some menus are too big, but most are not and the kinds of sites that need big menus often require interactivity with JavaScript anyways.
I wouldn’t really call this a CSS “hack” either. There is a checkbox that defines whether the menu is open, and CSS that styles the menu accordingly. I think that this is rather elegant really.
As soon as the :has pseudo class has widespread support, the checkbox can also just live inside the nav element, which removes the awkward general sibling combinator.
Using a checkbox is a hack in that you are using a <input> but not as a part of a form. The vestigial element gets rendered in all sorts of contexts where the CSS isn't downloaded or used. And even still, to get the ARIA you need for this menu to be accessible, you'll need to invoke JavaScript for to set the element attribute states anyhow. The anchor is a hack as well because it's not being used to link to any ID on in the document.
I also just gave this author's site a go. If I checked the box by using the keyboard, I can't close it with the mouse (or vise versa). It's a little funny as well since the menu items fit on the site without needing to make a menu button and at a small enough breakpoints it doesn't even break the items into multiple lines. Perhaps this is the anchor that's getting hit in the other case. ...And if the author had concerns about JavaScript, they would have done the syntax highlighting on the server side as well.
I wish there was an existing element for developers to just use though since it's a common pattern at this point. Then we wouldn't need to use said hacks or involve JavaScript that many users disable by default for security/privacy.
1. Someone finds out that you can use `:checked`.
2. They add some JavaScript to "enhance" their idea.
3. It's still less accessible than a proper implementation.
This example is a CSS hack and not something you would actually want to use in a production environment. JavaScript is absolutely necessary if you are developing a custom interactive element. If `<details>` works for you, fine. If it doesn't, you might want to look up ARIA attributes.
I feel like this is a fundamental misunderstanding of accessibility:
First of all, in many case the default choice provides accessibility for free. In this case it is the <details>/<summary> elements that other posts have highlighted.
Secondly, accessibility is not just about accommodating current visually impaired users, or providing power-users with mouse free experience. There are all sorts of impairments where accessibility will help. Your mouse might decide to die all of a sudden in a middle of a form, and they just need to click that submit button, the company might hire a visually impaired developer, a developer might get sick, or have an accident and return to work needing assistive technology, etc. The cases are numerous.
And finally, there are no excuses for not making your site accessible. If you are a front end developer, you know the industrial standard and you apply it. If you are not and are simply making a UI around an internal tool, you are probably either just using a rudimentary UI and browser native element (why do you need the hamburger menu in that case) or you use some UI framework that implements accessibility anyway.
The error in the console is:
> Cannot destructure property 'supabaseUrl' of 'Re(...)' as it is undefined.
I don't know if it's still true as I heard this state a few years ago, but at one point the growth rate of new web devs meant that at any given year, more than 50% of all web devs had less than 2 years of experience.
However, it's actually okay to introduce JS for the progressive enhancement to accessibility because ARIA is by definition dependent on RIAs.
In regards to the overall construction of these I also rather like the form:valid hack, rather than the checkbox hack depicted, since the former is more general (in particular, the selectors can be ancestors instead of siblings).
Now instead of lazily clicking from one random article to the next (or to a different language, or to "current events", or the "main page" of headline articles), one has to move the mouse twice and make two clicks to get to it through the hamburger menu, or use the URL bar. I can't even remember the last time I went back to the ToC when reading a Wikipedia article and this change is utterly incomprehensible to me.
I can't remember going purposely back to the ToC myself, however I often enough scroll over pages to find a section again and there it helps to have the structure visible.
However the nice thing: In your preferences you can pick the style you like. So if you want the old one pick it.
You can also leave feedback with them that "random page" is important (I like that one too!) so they find a better place ...
But the front page just has empty space there?!!??
I agree.
I put a hamburger menu in an in-house tool I built last year. Everyone in that department is between 22 and 30, with one guy over 50. I always stand with the users when my new products are deployed, so I was in the room when nobody recognized what the hamburger menu was.
I ended up changing it to the word "Menu" and everyone was happy.
I think it's becoming even more confusing now that Google is pushing the ⋮ vertical ellipsis as a hamburger replacement. The last thing the web needs is inconsistent icons.
Universally consistent icons only exist in rare cases, most of the time it is because a certain industry sits down and agrees on a standard (the power buttons are a good example; or the radioactivity and bio-hazard symbols), so inconsistent icons across the web is simply a reality that we have to live with as web designers. This makes our work both harder, but also more interesting.
I think you made the right choice removing the icon with text. Sometimes there is no icon which fits the context to provide meaning to it. In those cases, text is the correct choice.
Google uses a horizontally-scrolling menu bar for Images, News, etc., just above the search results when viewed on mobile: https://www.google.com/search?q=test
The horizontally-scrolling menu bar seems to be:
– Discoverable for typical visual browsers
– Discoverable for screen readers, especially when used with attributes like role="menu" and role="menuitem"
– Fully functional without JavaScript
> Put yourself in the shoes of a visually impaired person and think how frustrating it must be to get on a page that doesn’t allow you to open the main menu!
I just have to laugh at that kind of level of delusion. As if a screen reader will be able to figure out what the menu button is when the ids, classes and tags are all filled up with generated garbage by <insert unnecessary framework of choice>. It's not like the icon is labelled in any way that matters.
Any actually accessible or even good UX would have the menu buttons expanded by default, with text and not just icons. Mobile UIs have brought on this epidemic of hiding all features behind multiple superfluous clicks of icons hidden somewhere to the side and it just makes me feel like throwing up seeing it on desktop UIs. Even Wikipedia did it recently, despite the community backlash.
I also use 1440x900 on 24 inch monitors (I'm on the screen for 14 hours a day and don't like eye fatigue.) (1280x720 on 15 inch laptops -- most sites think I'm on mobile so even more clicks)
It’s used by Microsoft, Apple, Youtube... the list goes on. I think it’s not too much of a stretch to say that it is ubiquitous and familiar to users.
That being said, it's not the point of the article. There are definitely reasons not to use a hamburger button. But this article helps you build one if you want it.
I don't recollect ever having seen it on any of the 'small screens' (ie LCDs, etc) I used prior to smartphones.
"Designed and introduced" on the Xerox Star, which almost nobody used. It was quickly forgotten for 30 years, and only came back into use in 2009, according to Wikipedia.
It’s the old ‘three dots signify some sort of button’ pattern. Except these dots hide crucial functionality — think activate your campaign — and just kinda float in the middle of the row, surrounded by other actual buttons, and they don’t even have a border!
My parter figured it out eventually and when she said, hey, I found where that option is … that was a real head-slapping can it be this bad sort of moment.
From LI’s perspective this was days of income they didn’t get from us because we couldn’t figure out how to turn the damned thing on!
Hard to believe how this got through user testing.
But in trying to figure out when they became prominent, I discovered that some dude at Xerox invented them in 1981.
tl;dr "Discoverability is cut almost in half by hiding a website’s main navigation. Also, task time is longer and perceived task difficulty increases."
I have an (admittedly ancient) Android smartphone in my pocket which has dedicated physical menu and back buttons. I don't recall seeing hamburger menus until phone manufacturers started being too cheap to include that menu button.
Now they're everywhere, even (especially) when they're not remotely appropriate. What could be more ridiculous than a touchscreen-oriented menu button in a text editor (looking at you, Gedit) or a VCD waveform viewer (looking at you, GtkWave)?
Agreed, but you don’t want keyboard accessible menu items available for users that aren’t visually impaired. Offering a “show menu” button to screen readers is not less accessible to them than skipping the navigation section.
If you’re building a page that is only meant to be used by screen readers, then you are absolutely right.
> Meanwhile, non screen reader users are forced to guess what will be behind the ≡ button this time.
The main menu? Which is behind the same ≡ button on most pages on the internet?
And for your keyboard navigators using the visual interface, perhaps this hints that you could afford them a similar opportunity - where, from being focused on the menu, they could either descend into the menu, expanding it, or skip the menu and move focus to the next control. That’s how most OS/application keyboard accessible menus work - they don’t have ‘expand’ and ‘collapse’ affordances at all.
This triple dash thingy (≡) is in this case "identical to" Unicode character, so this is what you'd most probably hear from the screen reader. Other pages (mis)use similar characters, for example "Trigram for heaven". Not very helpful.
Truly accessible active elements must communicate their function through meaningful text, not cryptic astral Unicode from exotic blocks.
So is the ≡ the main navigation menu?
The account options menu?
The preferences menu?
The menu of the application platform that's wrapping the page you're on, rather than the page itself?
The menu showing all the sister companies of the site you're on?
Are you sure about that? I’m not an expert but I was under the impression that many screen reader users use the screen reader (among other tools) to interact with the visual representation of the user interface. Not all screen reader users are 100% blind (or at least that’s what I’ve been told), and actually use a variety of zooming, high contrast, magnifying glass, etc. and a screen reader.
If my impression is correct, then many screen reader user indeed open or close menus, and they are in the way (especially when zoom levels are pumped way up), and visually hiding them by default does offer a ton of usability benefits.
I'm not saying you need to enable it, but that is a choice you are making, and you have the skill to turn it on/off as needed, and realize that there may be sites you won't be able to use without it. I don't think it's a reasonable expectation today that JS may not be available, except maybe to display a nice warning page stating that.
Only if you want to polyfill for pre-2019 browsers
And it's odd because you can emulate W98, W2k, WXP and old GNU/Linux distros with damn ease in order to understand that no wm or desktop environment offerred a hamburger menu. And, trust me, lots of people tried zillions on WM's, tons of FVWM2 setups with bizarre configs highly divergent between themselves and no hamburguer button could be found in any of them.
And I can say the FVWM2 and fluxbox/blackbox guys were pioneers on lots of modern GUI trends and current minimalism or paradigm breaking shifts. If you were an UI designer for sure you tweaked FVWM2 and GTK2/QT3 themes to create weird and crazy things such as a dock composed of minified thumbnails created from windows, later done on Windows' Aero taskbar.
Like this:
https://fvwm.sourceforge.net/screenshots/desktops/
2003:
https://fvwm.sourceforge.net/screenshots/desktops/Nuno_Alexa...
2001:
https://fvwm.sourceforge.net/screenshots/desktops/Tavis_Orma...
Back in the day it wasn't used, period. Any software, either Win32, Motif, Delphi, Athena or such used a menu to access the most common items, the settings and a toolbar for functions. There was no icon replacing all of it.
The same with Macs. Mac OS 8, 9, and then, X. No hamburguer menu. The uberknown Mac menu and a set of Cocoa icons. That it.
https://cloudfour.com/thinks/a-details-element-as-a-burger-m...
On top of that we have people in this threat that use screen readers and claim that they have no problems with <details>/<summary> which aren’t present in other elements[1].
Some anecdotal evidence to support this.
I work for a very large health care company. We recently redesigned one of our portals. During the UX research phase, one of the tasks was to go back to the home page via the logo - one of the researchers had an idea we were assuming all of our users should/would know this since but we still have a large portion of our users are older, retirees or aging Gen Xers. It was a hunch at the time - nothing more.
The research showed a large enough percentage of people couldn't complete the task in a timely manner whereas on the new design, the logo is now just an SVG, with no link. We have a dedicated "Home" link now on the main navigation which in testing, 100% of the people were now able to complete the task in a timely manner.
I think it really stunned quite a few people since this has seemingly been a standard design pattern for so long. I was pretty stunned hearing the research team talking about it.
Why not both? Genuine question.
User never used/discovered it before == not familiar.
The problem, if there is one, is information hierarchy and deciding whether/how/where to disclose a given information at a given level in that hierarchy and how it’s disclosed. It’s very situationally dependent and probably impossible to please everyone. Optimizing it for the best outcomes for most users is what most good designs do, and they very seldom do the things a lot of vocal HN complaints want (shove everything on screen close together with small text, ie optimize for desktop power users; or make everything infinitely configurable, ie optimize for… idk even what the optimization serves, the same users complain about the web being overly complicated).
The new design vs the old design.
(It's perhaps worse in that way, since it's the tooling generating the HTML, of course, so this is just going to propagate…)
in any case, i agree that there's a lot going on to add affordances for keyboard users that screenreader users don't need. screenreaders would just need the <nav> element (probably should be aria-labeled too) and the <ul> link list.
it's neat but a little convoluted. i'd also vote for using a <button> rather than a checkbox plus anchors, but buttons do have technical limitations (as noted elsewhere) that browser engines should fix (similar to how dialog elements are now nearly javascript-less, only requiring a `showModal()` call to open), rather than having to have authors work around them.
<label for="menustate">
<span class="open">≡</span>
<span class="close">×</span>
</label>
So there still remains "readable" structure loosely identical to <label>identical to multiplication sign</label>
(With active CSS, only one half would be presented to SR, since the other has `display: none`, but still…)BTW Fact that wording of the link in the article pointing to the codepen is "this codepen" is also … not right.
However I misread the thread in my previous post.
Wait, what?
This might seem like I'm simply being contrarian or wanting stamp my rightitude on the matter, but your framing of the icon's absolute comprehension by everyone else seems to me to be ... ill-advised. Someone not doing their homework might just take your schpiel at face value and propagate problems obliviously.
I've 'beta'd' hamburger icons a few times over the years and have always come away not relying on them precisely because they don't seem to have the blanket comprehension amongst users you seem to think they do.
To me saying that something becomes something over a few decades doesn’t imply that it has been that way from the beginning. It has become a de facto standard over two decades doesn’t mean that it was a de facto standard two decades ago.
I feel like this is really not important, and I’ll change it to the last decade because it doesn’t matter. It’s definitely true that the adoption was most relevant in the last decade. I remember building hamburger menus over 20 years ago though.
What is more important is your second point that I sort of endorse hamburger buttons as a good UI element choice with this introduction. To me, this introduction was not meant to be controversial in any way. I believe that hamburger buttons are one of the most recognisable UI elements, and I don’t think that companies like Apple would use them without doing their homework.
That being said, it was not my intent to promote them as such. I didn’t do any profound research on the topic, and this article is not meant for user interface designers, but for developers that want or need to implement such a button because it either fits their use case or because the designers made the decision.
I’ll amend the intro to be more careful in the wording.
You came in a bit hot with your initial comment, but thanks for your feedback :)
FWIW I also used to use that quote, until I had a child and saw firsthand [well, second-hand as it was my wife doing the work] how much effort breastfeeding a newborn could take; I don't really blame anyone for quoting it (it's pithy after all).
Surprisingly good further discussion on the UX SE [1].
0: https://www.npr.org/sections/health-shots/2013/09/23/2253491...
1: https://ux.stackexchange.com/questions/5150/is-it-true-that-...
The fact that suckling is a hardwired reflex is what makes using the nipple intuitive. You use it by doing the same thing you think you should do.
In this case it gets used automatically without choice or thought. Anything shoved into a baby's mouth triggers it. It's not intuition, just reflex. Intuition implies understanding.
It's the difference between "I know that what this is for and how to use it" vs "I have no idea what this is and I have no control over doing it, this is just something that is happening to me"
It's become more of a meme to be needlessly contrarian, and ignore the fact that billions of babies actually do know this interface intuitively.
But beyond that (and this is covered in the stack overflow thread) is that it confuses intuition and reflex. Reflex is hard-wired and the stimulus often doesn’t even hit the brain - think a doctor tapping a kneecap. Suckling is like this, which is why a baby will root if you stroke its cheek - obviously there’s no nipple on the finger, yet the baby’s reflex kicks in nonetheless.
Intuition/intuitive on the other hand, in the context of UI design, means the user can without thinking or with very little conscious thought understand how to use the interface.
It's like quoting Einstein's bit about infinite stupidity, or the Dunning Kruger effect. It's dismissive without being insightful.
The reason the text wasn't wider is because long lines of text are hard to read. It's why newspapers typically arrange their text into columns, rather than having one article being 2-3 lines long stretching across the entire page.
The other issue is the placement of the menu in the upper right or left hand corner is nearly impossible to find with TalkBack or VoiceOver controls. Sometimes even with aria attributes, you really have to search with your finger to find the menu and interact with it.
BigCorps Inc. don't like these, because each menu choice has 3 departments and 14 sub-departments that mate-guard their particular menu area, so designers just give up on mobile and hide it all behind the hamburger icon.
It's absolutely daft. Your Web site should be an extra employee, never-tiring, always at work, facilitating the customer or visitor's needs. It's really weird, but depressingly predictable.
Enlarging the menu so its easier to find with screen reader tools like TalkBack and VoiceOver has been somewhat effective. However, if you have split menu's, login, search and other features, you start running into complex design issues with where to put all of those and whether you want to stuff them all in the mobile menu, outside the menu or a combination of the two. When you start putting features like search and login into the mobile menu, that also creates more accessibility issues as well.
Designing for accessibility can get really complex, really fast and I'm not sure there's really a solid design pattern yet that addresses all of the issues we're seeing now.
I know that's not a great answer, but it just highlights the complexity of designing for accessibility.
PDA's where a CEO/mid-boss/rich guy tools and nothing more, ditto with cell phones until late 90's.
The 99% of the people using software was doing that thru PC's and with a mouse and menu based WIMP interfaces, and not a smartphone based UI.
No, if anything it's the opposite. If you understand something, you'll find it easy to use. Intuition is what you rely on in the absence of understanding.
When you use VoiceOver for example, an easy test is dragging your finger down the middle of the screen, you should be able to access the majority of the content - when the menu is tucked too far up in the corner, or too small, it gets obscured by the logo, CTA or anything else that's in the area and gets bypassed by VoiceOver.
Making it large enough to find by simply dragging your finger down the middle of the screen is a good enough test to determine if its big enough, too small or located somewhere it would be skipped by those screen reader tools.
Hope that helps.