PetalComponents.Pagination (petal_components v4.13.0)

Copy Markdown View Source

Pagination is the method of splitting up content into discrete pages. It specifies the total number of pages and inidicates to a user the current page within the context of total pages.

Summary

Functions

In the path param you can specify :page as the place your page number will appear. e.g "/posts/:page" => "/posts/1"

Functions

pagination(assigns)

In the path param you can specify :page as the place your page number will appear. e.g "/posts/:page" => "/posts/1"

Attributes

  • path (:string) - page path. Defaults to "/:page".

  • class (:any) - parent div CSS class. Defaults to nil.

  • variant (:string) - numbered renders the windowed page list; simple renders Previous/Next outline buttons only - fewer decisions on short lists, and the honest form when a total is unreliable. Defaults to "numbered". Must be one of "numbered", or "simple".

  • previous_label (:string) - the previous button's label - visible in the simple variant, announced in the numbered one. Defaults to "Previous".

  • next_label (:string) - the next button's label - visible in the simple variant, announced in the numbered one. Defaults to "Next".

  • aria_label (:string) - names the navigation landmark, localizable. Defaults to "Pagination".

  • link_type (:string) - Defaults to "a". Must be one of "a", "live_patch", "live_redirect", or "button".

  • event (:any) - use phx-click events instead of linking (disables link_type and path). true fires the classic "goto-page" event; a STRING fires that event name instead - how the data table routes page changes through its single on_change grammar.

    Defaults to false.

  • target (:any) - the LiveView/LiveComponent to send the event to. Example: @myself. Will be ignored if event is not enabled. Defaults to nil.

  • total_pages (:integer) - sets a total page count. Defaults to nil.

  • current_page (:integer) - sets the current page. Defaults to nil.

  • sibling_count (:integer) - sets a sibling count. Defaults to 1.

  • boundary_count (:integer) - sets a boundary count. Defaults to 1.

  • show_boundary_chevrons (:boolean) - whether to show prev & next buttons at boundary pages. Defaults to false.

  • event_values (:map) - extra phx-value-* pairs sent with event-mode clicks, e.g. %{"op" => "page"}. Defaults to %{}.

  • Global attributes are accepted.