LanternUI.Components.Pagination (LanternUI v0.8.2)

Copy Markdown View Source

Pager + page-size control for paginated collections (a lantern-ui extension; Fluxon has no pagination component — this replaces flop_phoenix's pager).

Meta is duck-typed against Flop.Meta's shape (current_page, total_pages, page_size, total_count), so lantern_ui needs no flop dependency — pass a Flop.Meta struct or any map with those keys.

<.pagination meta={@meta} patch_fn={fn params -> ~p"/orders?#{params}" end} />

patch_fn receives %{page: n} or %{page: 1, page_size: s} and returns the patch path — the caller owns URL construction. Everything is patch-navigation, so pagination state lives in the URL.

Summary

Functions

pagination(assigns)

Attributes

  • meta (:map) (required) - Flop.Meta or any map with current_page/total_pages/page_size/total_count.
  • patch_fn (:any) (required) - fn %{page: n} | %{page: 1, page_size: s} -> path.

  • id (:string) - Base id for the page-size dropdown. Defaults to "pagination".
  • page_size_options (:list) - Choices in the page-size menu. Defaults to [10, 25, 50, 100].
  • show_page_size (:boolean) - Show the page-size dropdown control. Defaults to true.
  • sibling_count (:integer) - Page numbers shown on each side of current. Defaults to 1.
  • class (:any) - Extra classes merged onto the root element. Defaults to nil.
  • Global attributes are accepted. Arbitrary HTML/phx-* attributes passed through.