Etch component
Menu 1
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
menuslot: copy the header and edit its sample menu. ThemenuContentslot holds anavand 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-widthand--mac-menu-1-mobile-cta-marginon its menu. - The Reveal menu opens right below the header's bar, or
--space-xsbelow MAC Header 1's Floating box.--mac-menu-1-reveal-gapsets 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-activeand--mac-menu-1-link-bg-color-activeat the top level and in the phone menu, and inside a desktop dropdown--mac-menu-dropdown-1-link-color-activeand--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(desktopormobile), with the settings in use indata-mobile-menu-mode,data-mobile-dropdown-mode,data-desktop-dropdown-interaction,data-desktop-dropdown-mode,data-mobile-off-canvas-directionanddata-mobile-backdrop;aria-current="page"on the link to the current page anddata-has-current="true"on the button of each dropdown that holds it; anddata-mac-menu-open="true"on the page'sbodywhile the panel is open. - The demo's
navis named "Main menu" for screen readers (aria-label). If the page has another menu, such as a footer menu, give eachnavits own name.
Reference
Read from the component's JSON, so it's always current.
Loading the reference