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

# Paging

\`ff-paging\` builds pagination controls from FactFinder paging data. Use \`ff-paging-set\` and \`ff-paging-item\` to define links for each pagination state.

## Documentation

With the `ff-paging` element, you can build a custom paging for your search results.

A paging may contain several `ff-paging-set` elements, and each `ff-paging-set` element contains several `ff-paging-item` elements.

You can access the page number a paging item represents with the `{{page}}` syntax.

```html
<ff-paging id="paging2">
    <ff-paging-item type="currentLink -2">{{page}}</ff-paging-item>
    <ff-paging-item type="currentLink -1">{{page}}</ff-paging-item>
    <ff-paging-item type="currentLink" style="font-weight: bold;">{{page}}</ff-paging-item>
    <ff-paging-item type="currentLink +1">{{page}}</ff-paging-item>
    <ff-paging-item type="currentLink +2">{{page}}</ff-paging-item>
</ff-paging>
```

#### show-only

When the `show-only` attribute is present, the paging does not react to clicks.

```html
<ff-paging show-only>
    //...
</ff-paging>
```

### paging-set

Define different `ff-paging-set` elements based on which page you are on right now.

The `state` attribute is evaluated as a boolean expression. When its value is `true`, the `ff-paging-set` is visible.

The possible variables to build the expressions are `currentPage`, `pageCount`, and numeric values.

```html
<ff-paging>
    <ff-paging-set state="currentPage <= 3">
        ...
    </ff-paging-set>

    <ff-paging-set state="currentPage > 3 && pageCount-currentPage >= 3">
        ...
    </ff-paging-set>

    <ff-paging-set state="pageCount-currentPage < 3  && currentPage > 3">
        ...
    </ff-paging-set>
</ff-paging>
```

### paging-item

You can style the different `ff-paging-item` elements and define which links you want to display in a given paging-set.

This might look cumbersome and bloated, but it gives a very defined and in-depth way to design your paging element.

You have to set a `type` attribute in the `ff-paging-item` where you select a "page". This is an expression built from the possible values below:

* **firstLink**: Points to the first page.
* **lastLink**: Points to the last page.
* **nextLink**: Points to the next page if available. (`currentPage +1`)
  * *Usually this link is displayed as an arrow or something similar.*
* **previousLink**: Points to the previous page if available. (`currentPage -1`)
  * *Usually this link is displayed as an arrow or something similar.*
* **currentLink**: Points to the current page. You can add or subtract to define a specific page like `currentLink+2` or `currentLink-1`.

{% hint style="info" %}
The `ff-paging-item` will only be visible when the expression resolves to a valid page.
{% endhint %}

The paging-item also has a `show-only` attribute and works like the `show-only` on the paging itself.

Between the `ff-paging-items`, you can add placeholders such as `...`. They will always be visible.

#### Rendered HTML

The template you provide in an `ff-paging-item` tag will be rendered inside a wrapping `div`:

```html
<!-- Currently selected item -->
<ff-paging-item type="currentLink" class="ffw-selected">
	<div class="ffw-page-item-container ffw-cursor">1</div>
</ff-paging-item>

<!-- Regular visible and clickable item -->
<ff-paging-item type="currentLink +1" class="">
	<div class="ffw-page-item-container ffw-cursor">2</div>
</ff-paging-item>
```

### Example implementation

```html
<ff-paging id="paging3" class="paging3">
    <ff-paging-set id="p3set1" state="currentPage <= 3">
        <ff-paging-item type="previousLink">{{page}}</ff-paging-item>

        <ff-paging-item type="currentLink -2">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink -1">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink" style="font-weight: bold;">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink +1">{{page}}</ff-paging-item>
        ...
        <ff-paging-item type="nextLink">{{page}}</ff-paging-item>
        <ff-paging-item type="lastLink">last</ff-paging-item>
    </ff-paging-set>

    <ff-paging-set id="p3set2" state="currentPage > 3 && pageCount-currentPage >= 3">
        <ff-paging-item type="firstLink">{{page}}</ff-paging-item>

        <ff-paging-item type="previousLink">{{page}}</ff-paging-item>
        ...
        <ff-paging-item type="currentLink -1">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink" style="font-weight: bold;">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink +1">{{page}}</ff-paging-item>
        ...
        <ff-paging-item type="nextLink">{{page}}</ff-paging-item>

        <ff-paging-item type="lastLink">{{page}}</ff-paging-item>
    </ff-paging-set>

    <ff-paging-set id="p3set3" state="pageCount-currentPage < 3 && currentPage > 3">
        <ff-paging-item type="firstLink">first</ff-paging-item>
        <ff-paging-item type="previousLink">{{page}}</ff-paging-item>
        ...
        <ff-paging-item type="currentLink -1">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink" style="font-weight: bold;">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink +1">{{page}}</ff-paging-item>
        <ff-paging-item type="currentLink +2">{{page}}</ff-paging-item>

        <ff-paging-item type="nextLink">{{page}}</ff-paging-item>
    </ff-paging-set>
</ff-paging>
```

## Demo

{% embed url="<https://search-web-components.fact-finder.de/demos/5.x/ff-paging>" %}

## API

### `ff-paging`

#### Properties

| Name                                 | Description                                                          |
| ------------------------------------ | -------------------------------------------------------------------- |
| **paging** (Object) (default: empty) | The paging data from FactFinder.                                     |
| **show-only** (Boolean)              | Determines if page items should only be displayed and not clickable. |

#### Events

| Name            | Description                                                                                                                                  |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **dom-updated** | This event is triggered when the element has received new data and the template for this element and all sub elements have been punched out. |

### `ff-paging-set`

#### Properties

| Name                                 | Description                                                                                                                                                                   |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **state** (String) (default: "all")  | Sets the condition under which `ff-paging-set` becomes active. Use `currentPage` and `pageCount` in a calculation, such as `currentPage > 3 && pageCount - currentPage >= 3`. |
| **isActive** (Boolean)               | Determines if the paging set is currently active.                                                                                                                             |
| **paging** (Object) (default: empty) | The data from FactFinder.                                                                                                                                                     |

#### Methods

| Name           | Description           |
| -------------- | --------------------- |
| **hideSelf()** | Hides the paging set. |
| **showSelf()** | Shows the paging set. |

### `ff-paging-item`

#### Properties

| Name                                                                                                                       | Description                                                          |
| -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| **type** (String) **Options**: "currentLink", "firstLink", "lastLink", "nextLink", "previousLink" (default: "currentLink") | Configures and styles pages and navigation elements.                 |
| **show-only** (Boolean)                                                                                                    | Determines if page items should only be displayed and not clickable. |
| **page** (Number)                                                                                                          | The page number the item represents.                                 |


---

# 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/api/navigation/paging.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.
