Page 1 of 5
Usage
# <% In your controller %>
@pagy, @items = pagy(Item.all)
# <% In your view %>
<%= ui.pagy(pagy: @pagy) %>Props
| Prop | Type | Default | Description |
|---|---|---|---|
pagy | Pagy | - | A Pagy object containing pagination state (count, page, pages, etc.). |
class | String | nil | Additional 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) %>