# Header

## Header

**Files:** `src/config/config.toml`, `src/config/menu.<lang>.json`, `src/i18n/<lang>.json`, `src/pages/[...lang]/*.astro` · **Skill level:** Beginner (light code to change a page's layout)

Every header has the logo, the menu with its **Practice areas** mega menu and the **Home** and **Firm** dropdowns, a language menu, and a **Free consultation** button. Covena has three header layouts, and each homepage uses a different one. Below 1024 px the menu folds into a menu button that opens a side panel.

### The Three Layouts
**`panel`**: a white panel with a row of three contact chips ("Call us", "Email us", "Visit us") above the menu. Home 1 (`/`) floats it over the navy hero, and every inner page uses it with a thin outline.

<div class="border border-dark">
  ![Covena panel header with the contact chips above the menu](/images/covena/header-panel.jpg)
</div>

**`bar`**: a full-width white bar under a navy strip with links to the office cities and the phone number. Used on Home 2 (`/home-corporate/`).

<div class="border border-dark">
  ![Covena bar header with the office strip above it](/images/covena/header-bar.jpg)
</div>

**`transparent`**: white text over the hero photo, which turns into a solid white bar once the page scrolls. It also turns solid when a page loads already scrolled, after a reload or a link to a `#section`. It has the **Quick exit** button. Used on Home 3 (`/home-family/`).

<div class="border border-dark">
  ![Covena transparent header over the Home 3 hero photo, with the Quick exit button](/images/covena/header-transparent.jpg)
</div>

### Choose The Layout Of A Page
Each page picks its header in its route file in `src/pages/[...lang]/`, with props on `Base`:

```astro
---
// src/pages/[...lang]/home-corporate.astro
---
<Base {...data} headerVariant="bar" footerVariant="columns-light">
```

| Prop             | Values                              | What it does                                                                 |
| ---------------- | ----------------------------------- | ---------------------------------------------------------------------------- |
| `headerVariant`  | `panel` (default), `bar`, `transparent` | The header layout                                                        |
| `headerOverlay`  | `true` or `false` (default)         | `panel` only: the header floats over the first section, as on Home 1         |

A page that doesn't set `headerVariant` gets `panel`. Use `transparent` only on a page that opens with a full photo or a dark hero, because its text is white until the page scrolls.

### Header Settings
```toml
# src/config/config.toml
[settings]
  stickyHeader = true

[settings.header]
  showChips            = true
  showOfficeStrip      = true
  showLanguageSwitcher = true

[settings.navigationButton]
  enable = true
  label  = "" # Empty uses navigation.buttonLabel ("Free consultation")
  url    = "/consultation/"
```

| Setting                | What it does                                                                                       |
| ---------------------- | -------------------------------------------------------------------------------------------------- |
| `stickyHeader`         | `true` brings the menu bar back when visitors scroll up, and hides it while they scroll down. The chip row and the office strip always scroll away with the page |
| `showChips`            | The "Call us / Email us / Visit us" row in the `panel` header                                      |
| `showOfficeStrip`      | The strip above the `bar` header                                                                   |
| `showLanguageSwitcher` | The language menu in the header. It shows from 1320 px wide, where the header has room. Below 1024 px it is in the mobile menu, and the footer has a language menu at every width |
| `navigationButton`     | The button at the end of the menu. `label` empty uses `navigation.buttonLabel` in `src/i18n/<lang>.json` |

**Where the chips and strip get their text.** The phone and email come from `[settings.contactInfo]`, and the address in the "Visit us" chip from `contactInfo.address` in `src/i18n/<lang>.json`. The city links in the strip come from the office files in `src/content/offices/<language>/`, so a new office appears there by itself. The labels ("Call us", "Email us", "Visit us") are under `header` in each language file. See [Firm Info](/covena/customization/firm-info/).

### Quick Exit
The `transparent` header on Home 3 has a **Quick exit** button for visitors reading about family or domestic matters. It sends them to a neutral page at once, and pressing Escape twice does the same. `[settings.quickExit]` turns it off, changes where it goes, or adds it to every header:

```toml
[settings.quickExit]
  enable    = true
  everyPage = false
  url       = "https://www.bbc.co.uk/weather"
  label     = ""
```

With `everyPage = true` the button is also in the `panel` and `bar` headers and in the mobile menu. The header row then makes room for it: the language menu shows its short code (EN) below 1440 px, and the consultation button shows from 1320 px wide (from 1440 px in the `panel` header). The menu still has Contact, and the mobile menu keeps the consultation button. The full guide is [Quick Exit](/covena/features/quick-exit/).

### The Menu
The links in the header come from `headerPrimary` in `src/config/menu.<lang>.json`, one file per language. Covena ships seven items: **Home** (a dropdown of the three homepages), **Practice areas** (a mega menu with three groups and a bottom row), **Attorneys**, **Results**, **Firm** (a dropdown), **Insights**, and **Contact**. [Menus](/covena/customization/menus/) explains how to edit them, and [Navigation](/covena/features/navigation/) how the menu behaves.

### The Mobile Menu
Below 1024 px the menu button opens a side panel with the logo, the menu with submenus that open in place, the consultation button, the phone and email, and the language menu. It uses the same menu file as the desktop header, so there is nothing extra to edit.

<Aside type="tip">
  The header text in other languages takes more room. If you add long menu
  names, check the header at 1024 px and 1320 px wide in every language, where
  the row is tightest.
</Aside>

### Files For Developers
| File                                                         | What it does                                 |
| ------------------------------------------------------------ | -------------------------------------------- |
| `src/layouts/components/global/header/Header.astro`          | The three layouts, chips, strip, and buttons |
| `src/layouts/components/global/header/QuickExit.astro`       | The quick exit button and the Escape keys    |
| `src/layouts/components/global/header/LanguageSwitcher.astro` | The language menu                           |
| `src/layouts/components/widgets/HeaderOffcanvasContent.astro` | The mobile menu panel                       |
| `src/plugins/smartHeader.ts`                                 | Hides and shows the bar on scroll            |
| `src/styles/header.css`, `src/styles/smart-header.css`       | Header styles                                |

### Do It With AI
```text
In src/pages/[...lang]/about/index.astro, give the About page the "bar" header: add
headerVariant="bar" to the <Base> component and change nothing else. In src/config/config.toml set
[settings.navigationButton] url to "/contact/" and label to "", and set navigation.buttonLabel in
every file in src/i18n/ to "[LABEL]", translated. Then run npm run astro-check.
```