Search documentation of phoenix_kit

# PhoenixKitWeb.Components.Core.Pagination (phoenix_kit v1.7.87)

Copy Markdown View Source

Pagination components for list views in PhoenixKit.

Provides pagination controls and information display following daisyUI design patterns.

## Summary

### Functions

pagination(assigns)

Renders complete pagination controls with automatic URL building.

pagination_controls(assigns)

Displays pagination controls with page numbers and navigation buttons.

pagination_info(assigns)

Displays pagination information showing result range.

## Functions

# pagination(assigns)

Renders complete pagination controls with automatic URL building.

Simpler alternative to pagination_controls that handles URL building internally. Preserves all query parameters while changing page number.

## Attributes

- `current_page` - Current active page number (required)
- `total_pages` - Total number of pages available (required)
- `base_path` - Base URL path without query params (required)
- `params` - Map of query parameters to preserve (default: %{})

## Examples

    <.pagination
      current_page={@page}
      total_pages={@total_pages}
      base_path="/admin/emails"
      params={%{"search" => @filters.search, "status" => @filters.status}}
    />

    <%!-- Minimal usage --%>
    <.pagination
      current_page={1}
      total_pages={10}
      base_path="/admin/logs"
    />

## Attributes

- `current_page` (`:integer`) (required)
- `total_pages` (`:integer`) (required)
- `base_path` (`:string`) (required)
- `params` (`:map`) - Defaults to `%{}`.

# pagination_controls(assigns)

Displays pagination controls with page numbers and navigation buttons.

## Attributes

- `page` - Current page number (required)
- `total_pages` - Total number of pages (required)
- `build_url` - Function that takes page number and returns URL (required)
- `class` - Additional CSS classes

## Examples

    <.pagination_controls
      page={@page}
      total_pages={@total_pages}
      build_url={&build_page_url(&1, assigns)}
    />

## Attributes

- `page` (`:integer`) (required)
- `total_pages` (`:integer`) (required)
- `build_url` (`:any`) (required)
- `class` (`:string`) - Defaults to `""`.

# pagination_info(assigns)

Displays pagination information showing result range.

## Attributes

- `page` - Current page number (required)
- `per_page` - Items per page (required)
- `total_count` - Total number of items (required)
- `class` - Additional CSS classes

## Examples

    <.pagination_info
      page={@page}
      per_page={@per_page}
      total_count={@total_count}
    />

    # Renders: "Showing 1 to 25 of 100 results"

## Attributes

- `page` (`:integer`) (required)
- `per_page` (`:integer`) (required)
- `total_count` (`:integer`) (required)
- `class` (`:string`) - Defaults to `""`.