> For the complete documentation index, see [llms.txt](https://docs.fact-finder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fact-finder.com/webcomponents-overview/web-components-4.x./api/navigation/header-navigation.md).

# Header Navigation

Render three-level navigation in a hover menu.

## Documentation

### Using the Header Navigation

`ff-header-navigation` uses a different approach from other elements. Add the element to create a three-layer navigation.

```html
<ff-header-navigation></ff-header-navigation>
```

The first layer is the always-visible navigation bar. It contains FactFinder categories. The second and third layers appear when users hover over a first-layer element.

* Layer 2 contains groups.
* Layer 3 contains links inside a group.

### Configuration

`ff-header-navigation` provides options for loading and displaying data.

**`group-count`**

`group-count` controls how many layer-2 groups appear in the hover container. The default is `10`.

```html
<ff-header-navigation group-count="6"></ff-header-navigation>
```

**`group-size`**

`group-size` controls how many layer-3 links appear in each group. The default is `4`.

```html
<ff-header-navigation group-size="5"></ff-header-navigation>
```

**`hide-empty-groups`**

Set `hide-empty-groups` to hide groups without links. It defaults to `true`.

```html
<ff-header-navigation hide-empty-groups="false"></ff-header-navigation>
```

**`fetch-initial`**

Set `fetch-initial="false"` to load data manually. Call `fetch()` to load or reload the navigation.

```javascript
const nav = document.querySelector(`ff-header-navigation`);
nav.fetch();
```

```html
<ff-header-navigation fetch-initial="false"></ff-header-navigation>
```

### Dynamic content

Add custom content, such as an ad banner or group-specific image, around groups or after individual groups.

**Container slots**

Four container slots surround the group area: `top`, `bottom`, `left`, and `right`.

Add a `slot` attribute using this pattern:

```
container-[direction]-[group name]
```

This example adds content to every container slot for the `Bike` group:

```html
<style>
    .bike-top {
        height: 50px;
        background-color: #0b97c4;
        text-align: center;
        vertical-align: middle;
    }
</style>
<ff-header-navigation>
    <div slot="container-top-Bike" class="bike-top">bike - top</div>
    <div slot="container-bottom-Bike" class="bike-bottom">bike - bottom</div>
    <div slot="container-left-Bike" class="bike-left">bike - left</div>
    <div slot="container-right-Bike" class="bike-right">bike - right</div>
</ff-header-navigation>
```

**Group slots**

Use a group name as the slot name to add custom content after that group's links:

```html
<ff-header-navigation>
    <div slot="Outdoor jackets">
        <a href="https://www.myshop.de">
            More Outdoor jackets...
        </a>
    </div>
</ff-header-navigation>
```

### Rendered HTML

The internal navigation structure is fixed. Style it with CSS. A navigation can render the following structure:

```html
<ff-header-navigation>
    <div class="ffw-header-nav">
        <div class="ffw-header">
            <div class="ffw-nav-item-separator"></div>
            <ff-nav-element class="ffw-nav-item">
                <a href="...">Outdoor clothing</a>
            </ff-nav-element>
            <div class="ffw-nav-item-separator"></div>
            <ff-nav-element class="ffw-nav-item">
                <a href="...">Bike</a>
            </ff-nav-element>
            <div class="ffw-nav-item-separator"></div>
        </div>
        <div class="ffw-body">
            <div class="ffw-body-top">
                <div slot="container-top-Bike" class="bike-top">bike - top</div>
            </div>
            <div class="ffw-body-middle">
                <div class="ffw-body-left">
                    <div slot="container-left-Bike" class="bike-left">bike - left</div>
                </div>
                <div class="ffw-body-center">
                    <div class="ffw-nav-group">
                        <ff-nav-element class="ffw-nav-group-caption">
                            <a href="...">Bike parts</a>
                        </ff-nav-element>
                        <ff-nav-element class="ffw-nav-link">
                            <a href="...">Bike pedals</a>
                        </ff-nav-element>
                        <ff-nav-element class="ffw-nav-link">
                            <a href="...">Bike brakes</a>
                        </ff-nav-element>
                        <div slot="Bike parts">
                            <a href="https://www.myshop.de">More bike parts...</a>
                        </div>
                    </div>
                    <div class="ffw-nav-group">
                        <ff-nav-element class="ffw-nav-group-caption">
                            <a href="...">Bike accessories</a>
                        </ff-nav-element>
                        <ff-nav-element class="ffw-nav-link">
                            <a href="...">Bike lights</a>
                        </ff-nav-element>
                        <ff-nav-element class="ffw-nav-link">
                            <a href="...">Bike locks</a>
                        </ff-nav-element>
                    </div>
                </div>
                <div class="ffw-body-right">
                    <div slot="container-right-Bike" class="bike-right">bike - right</div>
                </div>
            </div>
            <div class="ffw-body-bottom">
                <div slot="container-bottom-Bike" class="bike-bottom">bike - bottom</div>
            </div>
        </div>
    </div>
</ff-header-navigation>
```

### Manipulating navigation URLs

FactFinder configures each navigation URL. Change them client-side when navigation must open a new page with a full reload. By default, `ff-header-navigation` changes pages in place.

Subscribe to the ResultDispatcher `navigation` event:

```javascript
document.addEventListener(`ffReady`, function (event) {
    const resultDispatcher = event.resultDispatcher;
    resultDispatcher.subscribe(`navigation`, function (navData, e) {
        // Set href values for all level-zero elements.
        navData[0].forEach(function (navEl) {
            navEl.__TARGET_URL__.setUrl(`/targetUrl`);
        });
    });
});
```

`navData` contains an array for each FactFinder cluster level:

```javascript
navData === [
    [{ clusterLevel: 0, ... }, ...],
    [{ clusterLevel: 1, ... }, ...],
    [{ clusterLevel: 2, ... }, ...],
    ...
]
```

Set a URL with `navEl.__TARGET_URL__.setUrl()`. Each navigation element also exposes `__SUB_ELEMENTS__`, an array containing its direct children.

## Demo

Try the [Header Navigation demo](https://search-web-components.fact-finder.de/demos/4.x/ff-header-navigation).

## API code

### Properties

<details>

<summary>Properties</summary>

| Name                                                                          | Description                                                |
| ----------------------------------------------------------------------------- | ---------------------------------------------------------- |
| **group-count** (Number) (default: 10)                                        | Number of layer-2 groups shown inside the hover container. |
| **group-size** (Number) (default: 4)                                          | Limits links rendered inside a group.                      |
| **hide-empty-groups** (String) **Options**: "true", "false" (default: "true") | Hides layer-2 groups with no layer-3 links.                |
| **fetch-initial** (String) **Options**: "true", "false" (default: "true")     | Requests navigation data on the first DOM attachment.      |
| **mouseenterDelay** (Number) (default: 600)                                   | Delays the mouse-enter event in milliseconds.              |
| **mouseleaveDelay** (Number) (default: 200)                                   | Delays the mouse-leave event in milliseconds.              |

</details>

### Methods

<details>

<summary>Methods</summary>

| Name        | Description                              |
| ----------- | ---------------------------------------- |
| **fetch()** | Triggers a new fetch of navigation data. |

</details>

### Events

<details>

<summary>Events</summary>

| Name            | Description                                                    |
| --------------- | -------------------------------------------------------------- |
| **dom-updated** | Triggered when the element receives data and templates render. |

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fact-finder.com/webcomponents-overview/web-components-4.x./api/navigation/header-navigation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
