# Navigation Menu

> Source: https://design.nanatec.co.ke/components/navigation-menu/
> The links across the top of a site or app, with panels of links that open under them. For layouts with a top bar instead of a sidebar.

The navigation menu is the main navigation of a layout without a sidebar. An item is a
link, or a button that opens a panel of links, each with a line saying what is behind it.
Put it at the start of the [top bar](/components/top-bar/). For an app with many sections,
use the [sidebar](/components/sidebar/) instead; for commands rather than pages, use the
[menubar](/components/menubar/).

## Preview

## Installation

```html
<nana-navigation-menu label="Site"></nana-navigation-menu>

<script type="module">
  document.querySelector('nana-navigation-menu').items = [
    { label: 'Home', href: '/', active: true },
    {
      label: 'Cover',
      items: [{ label: 'Motor', href: '/motor', description: 'Cars and motorbikes.' }],
    },
  ];
</script>
```

## Keyboard

| Key | Does |
| --- | --- |
| Tab | Moves through the items, and into an open panel |
| Left and Right arrows | Move along the row |
| Home and End | Go to the first or last item |
| Enter or Space on a button | Opens or closes its panel |
| Down arrow on a button | Opens its panel and moves to the first link |
| Up and Down arrows in a panel | Move between its links; Up from the first goes back to the button |
| Escape | Closes the panel and returns to its button |

A panel also closes on a click outside, or when focus leaves the menu.

## Phones

The row does not fold away by itself. On a narrow screen, hide it and put the same items
in a [drawer](/components/drawer/) opened from a button in the top bar.

## Accessibility

- The menu is a navigation landmark named by `label`, "Main" by default. Name each
  navigation on a page differently, such as "Site" and "Footer".
- The buttons are disclosure buttons: they say whether their panel is open, and the panel
  holds ordinary links, so a screen reader reads it as a list of links, not as a menu.
- The current page has `aria-current="page"`.

## API

`items` is required. `label` names the landmark. Other attributes go on the `nav`.
