Hamburger Menu Accessibility
Hamburger Menu Accessibility
Hamburger menu accessibility ensures the three-line menu icon pattern works for all users by providing proper labeling, keyboard support, and screen reader announcements. This common responsive navigation pattern requires explicit accessibility implementation.
What Is Hamburger Menu Accessibility
The hamburger menu uses a three-line icon (resembling stacked lines) to indicate a hidden menu. When activated, the icon reveals navigation options. This pattern conserves screen space on mobile devices and narrow viewports.
Accessibility challenges with hamburger menus include the icon’s lack of inherent meaning, the need to communicate menu state, and proper focus management when the menu opens and closes. The icon alone provides no accessible name for screen reader users.
WCAG requirements include providing accessible names for controls (4.1.2) and ensuring keyboard operability (2.1.1). The hamburger button must communicate its purpose and state to assistive technologies.
How Hamburger Menu Accessibility Works
The hamburger icon button requires an accessible name since the visual icon does not provide text content. Several approaches work:
- aria-label: Apply directly to the button
- Visually hidden text: Include screen-reader-only text inside the button
- aria-labelledby: Reference a visible or hidden label element
The button should communicate its expanded state using aria-expanded. When the menu is hidden, aria-expanded=“false”. When revealed, aria-expanded=“true”. Screen readers announce this state change.
The revealed menu should use nav element and list structure for proper semantics. When the menu opens, focus should move to the first menu item or the menu container. When the menu closes, focus should return to the hamburger button.
For menus that overlay content (rather than pushing it aside), focus trapping prevents keyboard users from navigating to obscured content. The menu behaves like a dialog in this case.
Animation of menu appearance should respect user motion preferences. The prefers-reduced-motion media query can disable or reduce animations for users who have indicated motion sensitivity.
Key Considerations
- Provide an accessible name describing the button’s purpose
- Use aria-expanded to communicate open/closed state
- Move focus appropriately when menu opens and closes
- Trap focus in overlay menus that obscure content
- Use semantic nav and list structure for menu content
- Ensure the hamburger button is keyboard accessible
- Respect motion preferences for menu animations
Common Questions
What accessible name should hamburger menus use?
Common accessible names include “Menu,” “Navigation menu,” “Main menu,” or “Open menu.” The name should clearly convey that activating the button reveals navigation options.
Avoid names that describe the icon appearance (“three lines”) rather than function. Users benefit from understanding what the button does, not what it looks like. Keep the name concise since screen readers announce it frequently during navigation.
Should the icon change when the menu is open?
Many implementations change the hamburger icon to an X (close icon) when the menu opens. This visual change helps sighted users understand how to close the menu. The accessible name should update accordingly: “Close menu” when open.
If implementing icon change with accessible name change, ensure the announcements make sense. Screen readers should announce “Menu button, expanded” or similar, with the name change providing additional context.
How should hamburger menus work with skip links?
Skip links help users bypass repetitive content like navigation. On mobile where the hamburger menu hides navigation by default, skip links may be less necessary when the menu is closed (since there is nothing to skip).
When the hamburger menu is open, skip links within the menu help users bypass lengthy navigation lists. The skip link pattern adapts to the menu state. Design systems should consider this interaction.
Summary
Hamburger menu accessibility provides proper labeling for the three-line icon, communicates menu state through aria-expanded, and manages focus when the menu opens and closes. This common pattern requires explicit accessibility implementation since the icon provides no inherent accessible meaning.
Buoy scans your codebase for design system inconsistencies before they ship
Detect Design Drift Free