Course contentsShow
← Web Development
Lesson 1170 of 2,98221. Accessible ComponentsFree lesson

Nested and Flyout Menus

Building accessible multi-level dropdown menus with proper hierarchy and keyboard navigation.

Nested and Flyout Menus

You'll learn how to build accessible multi-level dropdown menus that expand horizontally with proper keyboard support and ARIA relationships.

What Are Flyout Menus?

While basic dropdowns expand vertically downward, flyout menus (also called nested or hierarchical menus) contain submenus that open to the side. Think of a restaurant menu with categories like "Beverages" that reveals subcategories like "Hot Drinks" and "Cold Drinks" when you hover or navigate to it. Each submenu can contain its own items or even more submenus.

Semantic Structure

Nested menus maintain proper hierarchy using the same menu and menuitem roles you've learned, but parent items need additional ARIA:

  • Use aria-haspopup="menu" on any menuitem that opens a submenu
  • Add aria-expanded="false" when the submenu is closed, "true" when open
  • Each submenu is its own role="menu" nested inside its parent menuitem

Keyboard Navigation Pattern

Arrow key navigation extends to handle depth:

  • Right Arrow on a parent item opens its submenu and moves focus to the first item inside
  • Left Arrow closes the current submenu and returns focus to the parent item
  • Up/Down Arrows navigate within the current submenu level
  • Escape closes the current submenu (you already know this pattern!)

The roving tabindex pattern applies within each submenu level independently—only one item per visible menu should be focusable via Tab.

Focus Management Considerations

When opening a submenu, move focus to its first item. When closing (via Left Arrow or Escape), restore focus to the parent menuitem that triggered it. This maintains spatial awareness for keyboard and screen reader users navigating through multiple levels.

Key Takeaway: Flyout menus layer the menu navigation pattern you know with directional arrows (Right to open, Left to close) and ARIA attributes (aria-haspopup, aria-expanded) to communicate hierarchy and state across multiple levels.