© 2018 Domizio DemichelisMIT License


Pagy comes with a few optional extensions/extras:

Extra Description Links
array Paginate arrays efficiently avoiding expensive array-wrapping and without overriding array.rb, documentation
bootstrap Nav helper and templates for Bootstrap pagination bootstrap.rb, documentation
bulma Nav helper and templates for Bulma pagination component bulma.rb, documentation
compact An alternative UI that combines the pagination with the nav info in a single compact element compact.rb, documentation
i18n Use the I18n gem instead of the pagy implementation i18n.rb, documentation
items Allow the client to request a custom number of items per page with a ready to use selector UI items.rb, documentation
materialize Nav helper for Materialize CSS pagination component materialize.rb, documentation
out_of_range Allow for easy handling of out of range pages out_of_range.rb, documentation
responsive On resize, the number of page links will adapt in real-time to the available window or container width responsive.rb, documentation


Extras are not loaded by default, so you should require them explicitly in your initializer (see Configuration):

require 'pagy/extras/bootstrap'
require 'pagy/extras/...'


Extras don’t define any new module or class, they just re-open the Pagy class and modules, adding the extra methods as they were part of the loaded pagy gem. This neatly separates the core code from the optional extras, still keeping its usage as simple as it were part of the core.


All the added methods are documented in the respective extras.


The compact, items and responsive extras use javascript, so if you use any of them you should load the pagy.js file, and run Pagy.init() on window load.

In rails apps

Add the assets-path in the pagy.rb initializer:

Rails.application.config.assets.paths << Pagy.root.join('pagy', 'extras', 'javascripts')

Add the pagy javascript to the application.js:

//= require pagy

Add an event listener for turbolinks:

window.addEventListener("turbolinks:load", Pagy.init);

In non-rails apps

Ensure the pagy/extras/javascripts/pagy.js script gets served with the page and add an event listener like:

window.addEventListener('load', Pagy.init);

or execute the Pagy.init() using jQuery:

$( window ).load(function() {