Skip to content
New: Customize your theme with an AI assistant. Read the guide

Files: src/config/menu.<lang>.json · Skill level: Beginner

The header menu is built from one file per language. You write the links, and the theme handles the dropdown panel, the mega menu, the flyouts, the mobile menu, and keyboard support. For the header layouts and the header button, see Header. For the footer menus, see Menus.

How The Menu Behaves

On screens 1024 px wide and up:

  • Every dropdown and the mega menu share one floating panel. Moving from one menu to the next, the panel changes size and position instead of closing and opening again.
  • Hovering opens a menu, and moving away closes it after a short pause. A click or a key opens it too.
  • A nested item in a dropdown opens a flyout beside its list. A flyout that would run off the screen opens on the other side.
  • The menu item of the section you are in is marked as active.

Below 1024 px, the menu is a panel that slides in from the side. Dropdowns and the mega menu open inside it as accordions, and the panel ends with the consultation button, your phone and email, and the language menu. Focus stays inside the panel while it is open, and the page behind it doesn’t scroll.

In Arabic the menus mirror. See RTL & Arabic.

The Menu File

The header menu is the headerPrimary list in src/config/menu.en.json, and the same list in menu.fr.json and menu.ar.json. Items show in the order of the file.

1. A plain link

{ "enable": true, "name": "Contact", "weight": 7, "url": "/contact/" }

2. A dropdown. Set "hasChildren": true and list the links in children, as in “Firm”. A child with its own "hasChildren": true and children opens a flyout:

{
"enable": true,
"name": "Firm",
"weight": 5,
"hasChildren": true,
"children": [
{ "enable": true, "name": "About", "url": "/about/" },
{ "enable": true, "name": "Our history", "url": "/history/" },
{ "enable": true, "name": "Careers", "url": "/careers/" }
]
}

3. A mega menu. Set "hasMegaMenu": true and list groups of links in menus, as in “Practice areas”. Each group is a column with its name on top. Each link can have a one-line description. bar adds a row of links along the bottom of the panel:

{
"enable": true,
"name": "Practice areas",
"weight": 2,
"hasMegaMenu": true,
"menus": [
{
"enable": true,
"name": "For businesses",
"children": [
{
"enable": true,
"name": "Employment",
"description": "Contracts, dismissals and settlement agreements",
"url": "/practice-areas/employment/"
}
]
}
],
"bar": {
"enable": true,
"links": [
{ "enable": true, "name": "All practice areas", "url": "/practice-areas/" },
{ "enable": true, "name": "Industries we serve", "url": "/industries/" }
]
}
}

The mega menu is text only: it has no icons, images, or card. The demo has three groups: For businesses, For individuals, and Disputes & injury.

FieldUsed onWhat it does
enableEverythingtrue shows the item, false hides it without deleting it
nameEverythingThe text shown
weightTop-level itemsA position number. Keep it in step with the order in the file
urlLinks/fees/ for your own pages (the language prefix is added for you), or a full https:// address, which opens in a new tab
hasChildrenDropdowns, flyoutstrue when the item has children
childrenDropdowns, mega groupsThe links inside
hasMegaMenuTop-level itemstrue when the item opens a mega menu
menusMega menusThe groups of links. Each has enable, name, and children
descriptionMega menu linksA short line under the link
barMega menusenable, an optional text, and links, each with enable, name, and url

Keyboard Support

This works with no setup.

KeyWhat it does
Enter, Space, or ↓Opens the menu on the focused item and moves to its first link. ↑ moves to its last link
← and → on the menu barMove between the top-level items
↓ and ↑ in a panelMove through the links
→ on a nested itemOpens its flyout. ← or Escape goes back one level
Home and EndJump to the first or last item
TabMoves into the open panel, and out of it after the last link
EscapeCloses the menu and returns focus to the item that opened it

In Arabic, the left and right arrows swap. In the mobile panel, Escape closes the panel and returns focus to the menu button.

Files For Developers

FileWhat it does
src/layouts/components/global/header/Navbar.astroThe menu, on desktop and in the mobile panel
src/layouts/components/global/header/MenuItem.astroOne top-level item
src/layouts/components/global/header/NavStage.astroThe shared desktop panel and its script
src/layouts/components/global/header/NavStageDropdown.astro, NavStageList.astroDropdown content and its nested lists
src/layouts/components/global/header/NavStageMega.astroThe desktop mega menu
src/layouts/components/global/header/DropdownMenu.astro, MegaMenu.astroAccordions in the mobile panel
src/layouts/components/widgets/Offcanvas.astro, HeaderOffcanvasContent.astroThe mobile panel
src/styles/navigation.cssThe menu styles
src/lib/utils/navigationActive.tsMarks the current page in the menu

Do It With AI

Add a practice area link to the Covena mega menu. In every src/config/menu.<lang>.json,
in the "Practice areas" item of headerPrimary, add { "enable": true, "name": "[NAME]",
"description": "[ONE LINE]", "url": "/practice-areas/[SLUG]/" } to the group "[GROUP]".
Translate the name and description for each language. Keep the item shape the same and
don't change the components. Then run npm run astro-check.
Type something to search...