# `Flop.Phoenix.Pagination`
[🔗](https://github.com/woylie/flop_phoenix/blob/0.26.0/lib/flop_phoenix/pagination.ex#L1)

Defines a struct that holds the information needed to render a pagination
component.

# `t`

```elixir
@type t() :: %Flop.Phoenix.Pagination{
  current_page: pos_integer() | nil,
  ellipsis_end?: boolean(),
  ellipsis_start?: boolean(),
  next_cursor: String.t() | nil,
  next_direction: :previous | :next,
  next_page: pos_integer() | nil,
  page_range_end: pos_integer() | nil,
  page_range_start: pos_integer() | nil,
  pagination_type: Flop.pagination_type(),
  path_fun:
    (pos_integer() | nil -&gt; String.t())
    | (String.t() | nil, :previous | :next -&gt; String.t()),
  previous_cursor: String.t() | nil,
  previous_direction: :previous | :next,
  previous_page: pos_integer() | nil,
  total_pages: pos_integer() | nil
}
```

Describes the data needed to render a pagination component.

## For page-based pagination

- `current_page`
- `ellipsis_end?` - Whether an ellipsis should be rendered between the middle
  pagination links and the link to the last page.
- `ellipsis_end?` - Whether an ellipsis should be rendered between the link to
  the first page and the middle pagination links.
- `next_page`
- `page_range_start`, `page_range_end` - The range for the links for
  individual pages.
- `pagination_type` - In the case of page-based pagination, this is either
  `:page` or `:offset`.
- `path_fun` - 1-arity function that takes a page number and returns a path
  to that page that also includes query parameters for filters and sorting.
- `previous_page`
- `total_pages`

## For cursor-based pagination

- `next_cursor` - The cursor to be used for the link to the next page.
  Depending on the value of the `reverse` option, this is either the start
  cursor or the end cursor of the `Flop.Meta` struct.
- `next_direction` - The pagination direction for the link to the next page.
  If the `reverse` option is set to `true`, this will be `:previous`.
- `pagination_type` - In the case of cursor-based pagination, this is either
  `:first` or `:last`.
- `path_fun` - 2-arity function that takes a cursor and a direction and
  returns a path to that page that also includes query parameters for filters
  and sorting.
- `previous_cursor` - The cursor to be used for the link to the previous page.
  Depending on the value of the `reverse` option, this is either the start
  cursor or the end cursor of the `Flop.Meta` struct.

# `new`

```elixir
@spec new(
  Flop.Meta.t(),
  keyword()
) :: t()
```

Returns a `Pagination` struct for the given `Flop.Meta` struct.

## Options

- `page_links` - Defines how many page links to render. Only used for
  page-based pagination. Default: `5`.
- `path` - The path to the current page in the format as accepted by
  `Flop.Phoenix.build_path/3`. Default: `nil`.
- `reverse` - Reverses the position of the previous and next link. Only used
  for cursor-based pagination. Default: `false`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
