Pagy

Pagy component for pagination controls.

Page 1 of 5

Usage

# <% In your controller %>
@pagy, @items = pagy(Item.all)

# <% In your view %>
<%= ui.pagy(pagy: @pagy) %>
Props
PropTypeDefaultDescription
pagyPagy-A Pagy object containing pagination state (count, page, pages, etc.).
classStringnilAdditional CSS classes to apply to the pagination container.

Also accepts any HTML attributes via **options (e.g., id:, data:, aria:). class: is also supported for custom styling.

Examples

Basic pagination

Page 1 of 5
<% pagy = Pagy.new(count: 100, page: 1) %>
<%= ui.pagy(pagy: pagy) %>

Middle page

Page 5 of 10
<% pagy = Pagy.new(count: 200, page: 5) %>
<%= ui.pagy(pagy: pagy) %>

Custom items per page

Page 1 of 10
<% pagy = Pagy.new(count: 500, page: 1, limit: 50) %>
<%= ui.pagy(pagy: pagy) %>