PUI.Pagination (pui v1.0.0)

Copy Markdown

Accessible, host-controlled pagination links.

Pagination renders navigation markup and page links. It does not load data, change LiveView assigns, or decide how URLs are built. Pass a one-argument page_url function and choose whether links use href, navigate, or patch.

Example

<.pagination
  current_page={@page}
  total_pages={@total_pages}
  page_url={fn page -> ~p"/projects?page=#{page}" end}
  link_mode="patch"
/>

Attributes

NameTypeDefaultDescription
current_pageintegerrequiredCurrent one-based page
total_pagesintegerrequiredTotal one-based page count
page_urlfunctionrequiredFunction receiving a page number
link_modestring"patch""href", "navigate", or "patch"
windowinteger2Pages shown around the current page
aria_labelstring"Pagination"Navigation landmark label
classstring""Additional CSS classes
restglobalGlobal HTML attributes

Slots

previous, next, and page are optional slots. The page slot receives the page number through :let and can replace the default numeric label.

Summary

Functions

pagination(assigns)

Attributes

  • current_page (:integer) (required)
  • total_pages (:integer) (required)
  • page_url (:any) (required)
  • link_mode (:string) - Defaults to "patch". Must be one of "href", "navigate", or "patch".
  • window (:integer) - Defaults to 2.
  • aria_label (:string) - Defaults to "Pagination".
  • class (:string) - Defaults to "".
  • Global attributes are accepted.

Slots

  • previous
  • next
  • page