# Navigation & Mega Menu

## Navigation & Mega Menu

**Files:** `src/config/menu.<language>.json` · **Skill level:** Beginner

The header menu is built from one file per language. You write the links, and the theme draws the dropdown panel, the Properties mega menu, the flyouts, the phone menu and the keyboard support. For the header layouts, the logo and the header button, see [Header](/lotline/customization/header/). For a shorter guide to the menu file, see [Menus](/lotline/customization/menus/).

<div class="border border-dark">
  ![The Lotline header over the Home 1 hero](/images/lotline/home.jpg)
</div>

### How The Menu Behaves
On large screens:

- Every dropdown and the mega menu share one panel. Moving from one menu to the next, the panel changes width, height and position while the content slides in the direction you moved.
- A nested item, such as **Homepages** inside **Company**, opens a flyout beside its list. A flyout that would run off the screen opens on the other side.
- Menu rows are text only: a name and an optional one-line description. There are no icons in the menu.

On phones and tablets the menu is a slide-in panel. Submenus open and close like an accordion, and the call button, the main button and the language links sit at the bottom of the panel. Focus stays inside the panel while it's open.

Visitors who turn on **reduce motion** get a simple fade instead. On Arabic pages everything mirrors: see [RTL & Arabic](/lotline/features/rtl-arabic/).

### The Menu File
There is one file per language: `src/config/menu.en.json`, `menu.fr.json` and `menu.ar.json`. The header menu is the `headerPrimary` list, and the footer columns are `footer`.

There are three kinds of item.

**1. A plain link**

```json
{ "enable": true, "name": "Agents", "weight": 4, "url": "/agents/" }
```

**2. A dropdown.** Set `"hasChildren": true` and list the links in `children`. A child can have a short `description`, and it can have its own `"hasChildren": true` and `children`, which opens a flyout:

```json
{
  "enable": true,
  "name": "Company",
  "weight": 5,
  "hasChildren": true,
  "children": [
    {
      "enable": true,
      "name": "Homepages",
      "weight": 0,
      "hasChildren": true,
      "children": [
        { "enable": true, "name": "Agency home", "description": "Homes for sale and for rent", "url": "/", "weight": 1 }
      ]
    },
    { "enable": true, "name": "About us", "url": "/about/", "weight": 1 }
  ]
}
```

**3. The Properties mega menu.** Set `"hasMegaMenu": true` and list groups of links in `menus`. `featured` adds a listing card on the side, and `bar` adds a strip along the bottom with a link and your phone number from `[business]`:

```json
{
  "enable": true,
  "name": "Properties",
  "weight": 1,
  "hasMegaMenu": true,
  "menus": [
    {
      "enable": true,
      "name": "Search",
      "weight": 1,
      "children": [
        { "enable": true, "name": "For sale", "description": "Homes on the market now", "url": "/properties/?status=sale", "weight": 1 },
        { "enable": true, "name": "For rent", "description": "Homes and apartments for rent", "url": "/properties/?status=rent", "weight": 2 }
      ]
    }
  ],
  "featured": {
    "enable": true,
    "label": "Featured listing",
    "image": "/images/lotline/properties/elm-hill-modern-villa/cover.jpg",
    "title": "Five-bedroom villa with city views",
    "price": "$1,920,000",
    "url": "/properties/elm-hill-modern-villa/",
    "linkLabel": "View the home"
  },
  "bar": {
    "enable": true,
    "text": "Thinking of selling?",
    "label": "Book a valuation",
    "url": "/valuation/"
  }
}
```

Mega menu links can point at a filtered search, such as `/properties/?status=rent` or `/properties/?type=house`. The properties page reads those values and sets its filters to match. See [Listing Search & Filters](/lotline/customization/listing-search/).

The featured card's `title` and `price` are typed text, so update them when that home sells or its price changes.

### Menu Fields
| Field | Used on | What it does |
| --- | --- | --- |
| `enable` | Everything | `true` shows the item and `false` hides it |
| `name` | Everything | The text shown |
| `weight` | Everything | A position number. Keep it in step with the order in the file |
| `url` | Links | `/agents/` for your own pages (the language prefix is added for you), or a full `https://` address |
| `description` | Dropdown and mega menu links | A short line under the name |
| `hasChildren` | Dropdowns, flyouts | `true` when the item has `children` |
| `children` | Dropdowns, mega menu groups | The links inside. Items in a dropdown can have their own `children` |
| `hasMegaMenu` | Top-level items | `true` when the item opens a mega menu |
| `menus` | Mega menu | The groups of links, each with `enable`, `name`, `weight` and `children` |
| `featured` | Mega menu | The listing card: `enable`, `label`, `image`, `title`, `price`, `url`, `linkLabel` |
| `bar` | Mega menu | The bottom strip: `enable`, `text`, `label`, `url` |

A menu item with children opens its menu instead of going to a page, so put its own page first in its `children` if it has one.

<Aside type="caution">
  Change the menu file of **every language** when you add or remove a link,
  so the menus stay in step. `npm run check-i18n` reports a menu that differs.
  JSON is strict: a missing comma, or a comma after the last item, stops the
  site from building.
</Aside>

### Keyboard Support
This works with no setup.

| Key | What it does |
| --- | --- |
| `Enter` or `Space` | Opens the menu on the focused item |
| `Down` and `Up` | Move through the links in the open list |
| `Left` and `Right` | Move between menus, and in and out of flyouts |
| `Home` and `End` | Jump to the first or last link in the list |
| `Tab` | Moves into the panel, in reading order |
| `Escape` | Closes the menu and returns focus to where it was |

In the phone menu, `Escape` closes the panel and returns focus to the button that opened it.

### Files For Developers
| File | What it does |
| --- | --- |
| `src/layouts/components/global/header/SiteHeader.astro` | The header, its three layouts and the header button |
| `src/layouts/components/global/header/Navbar.astro` | The menu in the header |
| `src/layouts/components/global/header/NavStage.astro` | The shared panel and its script |
| `src/layouts/components/global/header/NavStageDropdown.astro` | Dropdown content |
| `src/layouts/components/global/header/NavStageList.astro` | The list that repeats for each nested level |
| `src/layouts/components/global/header/NavStageMega.astro` | The mega menu, its featured card and bottom strip |
| `src/layouts/components/widgets/HeaderOffcanvasContent.astro` | The phone menu |
| `src/styles/navigation.css` | The menu styles |

### Do It With AI
```text
In src/config/menu.en.json, menu.fr.json and menu.ar.json, add a "[NAME]" link to the
[Company | Services] dropdown in headerPrimary, pointing to [URL], with a one-line description.
Keep the same item shape as the other items, translate the name and description, and keep the
three files in the same order. Then run npm run check-i18n.
```