Etch component

Menu 1

Menu 1

Copy Menu 1

Configurator settings

Change a setting in the configurator to include it.

Optional. Copies the component under its own name, such as News Card Alpha for a site.

Documentation

The menu inside MAC Header 1: links and dropdowns in a row on desktop and, up to 992px wide, a panel that the header's Menu button opens.

How to use it

  • It comes in MAC Header 1's menu slot: copy the header and edit its sample menu. The menuContent slot holds a nav and its list, with MAC Menu Link 1s for links and MAC Menu Dropdown 1s for dropdowns.
  • Its settings are As the Header by default, so the header's props set them. Pick another value here for this menu only.
  • Desktop Settings: dropdowns open on hover and click, or on click only (Desktop Dropdowns Open On), and animate as separate dropdowns or as one panel that morphs from one to the next (Desktop Dropdowns Animation).
  • Mobile Settings: the panel opens Off Canvas, sliding in from the edge Off Canvas Direction sets, or Reveal, down from the header, with an optional backdrop in either. Dropdowns open as an Accordion or Stacked, a panel of their own with a back button.

Good to know

  • The switch to the panel is in the CSS, at 992px (--mac-l), so the page shows the right menu before any script runs.
  • It needs a header around it for the panel's position, such as MAC Header 1. Alone, it logs a warning in the console, and As the Header means Off Canvas from the right without a backdrop, Accordion dropdowns, Hover and Click, and Dropdown.
  • Use one MAC Menu 1 per page: its script starts one menu, and the header's Menu button opens it by its id, mac-menu-1. Another menu on the page, such as the footer's links, needs another component.
  • In MAC Header 1 with Bar, the Off Canvas panel is as wide as the screen; with Floating it takes the box's place. Either way a link shown as a button sits at its bottom: the header sets --mac-menu-1-mobile-width and --mac-menu-1-mobile-cta-margin on its menu.
  • The Reveal menu opens right below the header's bar, or --space-xs below MAC Header 1's Floating box. --mac-menu-1-reveal-gap sets that space, the same in every look.
  • A link shown as a button (MAC Menu Link 1's Show As) keeps ACSS's button styles: the menu's link styles skip it.
  • The link to the current page, and the button of a dropdown that holds it, take the active colors: --mac-menu-1-link-color-active and --mac-menu-1-link-bg-color-active at the top level and in the phone menu, and inside a desktop dropdown --mac-menu-dropdown-1-link-color-active and --mac-menu-dropdown-1-link-bg-color-active, which default to those. In Windows contrast themes they're underlined, and the Morph and Off Canvas panels have a line around them.
  • The --mac-menu-1-* variables set the links' colors, padding, radius and focus color, and the panel's background, width, padding, dividers and position.
  • Its states are attributes: on the menu, data-mode (desktop or mobile), with the settings in use in data-mobile-menu-mode, data-mobile-dropdown-mode, data-desktop-dropdown-interaction, data-desktop-dropdown-mode, data-mobile-off-canvas-direction and data-mobile-backdrop; aria-current="page" on the link to the current page and data-has-current="true" on the button of each dropdown that holds it; and data-mac-menu-open="true" on the page's body while the panel is open.
  • The demo's nav is named "Main menu" for screen readers (aria-label). If the page has another menu, such as a footer menu, give each nav its own name.

Reference

Read from the component's JSON, so it's always current.

Loading the reference