๐ RailsPaginationUltimate
The ultra-premium, high-performance pagination powerhouse for modern Rails applications.
RailsPaginationUltimate is built for developers who need more than just simple page links. It is a feature-rich, "Best-in-Class" replacement for Kaminari and WillPaginate, offering pro-grade UI components, native Tailwind CSS support, and advanced interactivity out of the box.
๐ Key Features
- โก Pro Performance:
without_countmode for lightning-fast paging on multi-million row tables. - ๐จ Premium UI Styles: Standard numbers, "Load More" buttons, and automated "Infinite Scroll".
- ๐ Native Tailwind Support: First-class support for Tailwind CSS utility classes.
- โจ๏ธ Keyboard Navigation: Use Left/Right arrows to flip through pages.
- ๐ History API: AJAX updates automatically sync with the browser's URL and Back button.
- ๐ 100% Localizable: Full I18n support for all labels, icons, and result strings.
- ๐ Advanced Helpers: Integrated
page_entries_infoandper_page_selectcomponents. - ๐งฉ Total Customization: Easy-to-use generator to export and modify HTML templates.
๐ฆ Installation
Add this line to your application's Gemfile:
gem 'rails_pagination_ultimate', github: 'shiboshreeroy/rails_pagination_ultimate'
And then execute:
bundle install
๐ Usage
1. Basic Pagination
In your controller:
@posts = Post.page(params[:page]).per(25)
In your view:
<%= paginate @posts %>
2. Pro Navigation Modes
๐ฑ Infinite Scroll (Modern Feed)
Automatically loads content as the user scrolls. Requires a target CSS selector.
<div id="posts-container">
<%= render @posts %>
</div>
<%= paginate @posts, type: :infinite_scroll, target: "#posts-container" %>
๐ฑ "Load More" Button
A premium button that appends results without a full page reload.
<%= paginate @posts, type: :load_more, target: "#posts-container" %>
โจ๏ธ Keyboard & History Support
Enable pro-level accessibility and shareable URLs for AJAX pagination:
<%= paginate @posts, theme: :tailwind, keyboard: true, history: true %>
โก Performance Optimization
Fast Mode (without_count)
Traditional pagination runs a COUNT(*) query which can be slow on large tables. RailsPaginationUltimate's "Fast Mode" skips this count entirely and uses an efficient look-ahead check for the next page.
# Controller
@posts = Post.without_count.page(params[:page]).per(50)
๐จ Customization & Theming
A. Tailwind CSS (Recommended)
Use pro-grade Tailwind components by simply passing theme: :tailwind. No extra CSS files required!
<%= paginate @posts, theme: :tailwind, first_last: true, window: 3 %>
B. CSS Variables (Default Theme)
If you're not using Tailwind, the default theme is built with clean CSS variables for instant global styling:
:root {
--rp-primary-color: #3b82f6; /* Your Brand Color */
--rp-border-radius: 0.5rem;
--rp-text-color: #1f2937;
--rp-bg-color: #ffffff;
}
C. Total UI Control (Generator)
Need to change the HTML? Export the Pro Tailwind template to your app:
rails generate rails_pagination_ultimate:tailwind
This creates app/views/rails_pagination_ultimate/_pagination.html.erb. You can then use it like this:
<%= paginate @posts, template: "rails_pagination_ultimate/pagination" %>
๐ Results Management
Detailed Information
Displays "Showing 1-25 of 150 results".
<%= page_entries_info @posts %>
Dynamic "Per Page" Selector
Let users choose how many items they want to see.
<%= per_page_select @posts, choices: [25, 50, 100], label: "Items per page:" %>
๐ Localization (I18n)
Everything is translatable in config/locales/en.yml:
en:
rails_pagination_ultimate:
previous: "โ Previous"
next: "Next โ"
first: "ยซ First"
last: "Last ยป"
info:
other: "Showing <b>%{first}-%{last}</b> of <b>%{total}</b> results"
without_count: "Showing <b>%{first}-%{last}</b> results"
๐ Options Reference
| Option | Type | Default | Description |
|---|---|---|---|
theme |
Symbol | nil |
Set to :tailwind for Tailwind UI. |
type |
Symbol | :standard |
:standard, :load_more, or :infinite_scroll. |
target |
String | nil |
CSS selector for where to append new items (AJAX). |
window |
Integer | 2 |
Number of page links around the current page. |
first_last |
Boolean | false |
Show "First" and "Last" page links. |
keyboard |
Boolean | false |
Enable Left/Right arrow key navigation. |
history |
Boolean | false |
Update browser URL/history on AJAX paging. |
template |
String | nil |
Path to a custom partial for rendering. |
โ๏ธ Why switch from Kaminari?
| Feature | RailsPaginationUltimate | Kaminari |
|---|---|---|
| Native Tailwind UI | โ Built-in | โ No |
| Infinite Scroll | โ Built-in | โ No |
| Fast Mode (No Count) | โ Native | โ Plugin required |
| Keyboard Shortcuts | โ Built-in | โ No |
| History API Sync | โ Built-in | โ No |
| Interactive Per-Page | โ Built-in | โ No |
| Modern Flexbox CSS | โ Yes | โ No |
๐จโ๐ป Author & Credits
RailsPaginationUltimate is developed and maintained by Shiboshree Roy.
- Developer & Author: Shiboshree Roy
- Powered By: Shiboshree Roy
Built with โค๏ธ for the Rails community.
๐ License
The gem is available as open source under the terms of the MIT License.