> 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/navigation.md).

# Navigation

Render hierarchical FactFinder navigation.

## Documentation

### Using the Navigation

To start an `ff-navigation`, define at least one `ff-navigation-item`. This template renders every navigation element.

```html
<ff-navigation>
    <ff-navigation-item>
        <div>{{name}}</div>
    </ff-navigation-item>
</ff-navigation>
```

## Demo

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

## API code

### `ff-navigation`

**Properties**

<details>

<summary>Properties</summary>

| Name                                          | Description                                              |
| --------------------------------------------- | -------------------------------------------------------- |
| **layout** (String, default: `"horizontal"`)  | Layout direction: `"vertical"` or `"horizontal"`.        |
| **flyout** (String, default: `"true"`)        | Expands sub-elements outside their parent.               |
| **mobile** (String, default: `"false"`)       | Shows mobile navigation behavior.                        |
| **fetch-initial** (String, default: `"true"`) | Requests navigation data when first attached to the DOM. |
| **first-fetch** (Number, default: `2`)        | Navigation levels requested during initial loading.      |
| **fetch-size** (Number, default: `1`)         | Levels requested by subsequent fetches.                  |
| **max-fetch** (Number, default: `10`)         | Maximum navigation depth to load.                        |
| **fetch-time** (Number, default: `100`)       | Delay between navigation requests, in milliseconds.      |
| **subscribe** (String, default: `"true"`)     | Subscribes to FactFinder navigation data.                |
| **navigationData** (Array)                    | Navigation data used to render the element.              |

</details>

**Methods**

<details>

<summary>Methods</summary>

| Name               | Description                                              |
| ------------------ | -------------------------------------------------------- |
| **fetch()**        | Fetches navigation data before initialization.           |
| **updateLayout()** | Recalculates child directions for the configured layout. |

</details>

**Events**

<details>

<summary>Events</summary>

| Name            | Description                                                      |
| --------------- | ---------------------------------------------------------------- |
| **dom-updated** | Fires after the element receives data and renders its templates. |

</details>

### `ff-navigation-item`

**Properties**

<details>

<summary>Properties</summary>

| Name                                            | Description                                                       |
| ----------------------------------------------- | ----------------------------------------------------------------- |
| **element** (Object)                            | Category data from the navigation tree.                           |
| **direction** (String, default: `"right"`)      | Expansion direction: `"left"`, `"right"`, or `"down"`.            |
| **cluster-level** (Number, default: `0`)        | Internal level value used for placement and styling.              |
| **type** (String, default: `"default"`)         | Template type: `"default"`, `"header"`, `"parent"`, or `"level"`. |
| **has-subelements** (Boolean, default: `false`) | Indicates whether the item has child elements.                    |
| **flyout** (String, default: `"true"`)          | Expands child elements outside or inside the parent.              |
| **selected** (Boolean, default: `false`)        | Indicates the selected item in mobile mode.                       |

</details>

Navigation elements are categories in a tree. The item template can access `name` and `recordCount`.

```html
<style>
    .my-item {
        background-color: white;
        padding: 5px;
        min-width: 150px;
    }
</style>
<ff-navigation>
    <ff-navigation-item>
        <div class="my-item">{{name}}</div>
    </ff-navigation-item>
</ff-navigation>
```

### Templates

Use `type="header"` for the first level. Use `type="parent"` for items with children. Use `type="layerN"` for a specific navigation level.

`parent` takes priority over a matching layer template. Elements with children receive `has-subelements`. Each item receives `cluster-level`.

**Header template**

```html
<ff-navigation>
    <ff-navigation-item>
        <div class="my-item">{{name}} ({{recordCount}})</div>
    </ff-navigation-item>
    <ff-navigation-item type="header">
        <div class="my-header">{{name}}</div>
    </ff-navigation-item>
</ff-navigation>
```

**Parent template**

```html
<ff-navigation>
    <ff-navigation-item type="parent">
        <div class="my-item my-parent-item">
            {{name}}
            <img src="arrow-right.png" />
        </div>
    </ff-navigation-item>
</ff-navigation>
```

**Layer template**

```html
<ff-navigation>
    <ff-navigation-item type="layer1">
        <div class="my-layer1">{{name}}</div>
    </ff-navigation-item>
    <ff-navigation-item type="layer2">
        <div class="my-layer2">{{name}}</div>
    </ff-navigation-item>
</ff-navigation>
```

### Layouts

Use `layout="vertical"` or `layout="horizontal"`. Give vertical navigation an explicit width.

```html
<style>
    ff-navigation {
        width: 250px;
    }
</style>
<ff-navigation layout="vertical">
    <ff-navigation-item>
        <div>{{name}}</div>
    </ff-navigation-item>
</ff-navigation>
```

### Responsiveness

For responsive layouts, provide a `slot="menu"` element. Set `mobile="true"` in your resize logic. Use `data-search` on a child control to navigate through a parent item on touch devices.

```html
<script>
    window.addEventListener("resize", function (evt) {
        const navigation = document.querySelector("ff-flyout-navigation");
        if (window.innerWidth < 600) {
            navigation.setAttribute("mobile", "true");
        } else {
            navigation.setAttribute("mobile", "false");
        }
    });
</script>
<ff-navigation layout="horizontal">
    <div slot="menu">Navigation</div>
    <ff-navigation-item>
        <div class="my-item">
            <img data-search class="search-icon" src="search-icon.png" />
            {{name}}
        </div>
    </ff-navigation-item>
</ff-navigation>
```

### Custom navigation data

Set `subscribe="false"` and assign an array to `navigationData`. Each item needs `clusterLevel`, `name`, and `__SUB_ELEMENTS__` values.

```html
<script>
    const navigationCustomData = [
        {
            "associatedFieldName": "CategoryROOT",
            "clusterLevel": 0,
            "name": "Outdoor clothing",
            "__SUB_ELEMENTS__": [
                {
                    "associatedFieldName": "CategoryROOT/Outdoor clothing",
                    "clusterLevel": 1,
                    "name": "Outdoor jackets",
                    "__SUB_ELEMENTS__": []
                }
            ]
        }
    ];
    document.addEventListener("WebComponentsReady", function (evt) {
        const navigation = document.querySelector("ff-navigation");
        navigation.navigationData = navigationCustomData;
    });
</script>
<ff-navigation layout="horizontal" subscribe="false">
    <div slot="menu">Navigation</div>
    <ff-navigation-item>
        <div class="my-item">{{name}}</div>
    </ff-navigation-item>
</ff-navigation>
```


---

# 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/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.
