RRUI-006 · Pagination · Alignment · Mobile
On a narrow viewport, rui_pagination with align: :left | :center | :right | :between clips out of its parent. Center and right look especially wrong: controls spill off the opposite edge instead of sitting inside the card. Visible on the RapidRails docs Alignment section in mobile mode.
justify-* then aligns that overflowing row as a unit.
| Component | RapidRailsUI::Pagination::Component |
|---|---|
| Surface | Docs Alignment examples; any host card narrower than the numbered row (~phone width) |
| Trigger |
variant: :numbered (default) + any align: + viewport / parent < sm
|
| Symptom |
:left / :between clip on the right; :center clips both sides; :right clips on the left |
align: :left, :center, :right, :between.<%= rui_pagination(current_page: 3, total_pages: 8, total_count: 80, align: :center) %>
<% page_series.each do |item| %>
<% if item == :gap %>
<span class="…ellipsis…">…</span> <%# never hidden %>
<% elsif item == current_page %>
<span class="…active button…"><%= item %></span> <%# never hidden %>
<% else %>
<%= link_to item, …, class: "#{button_classes} #{responsive_hide_mobile_classes}" %>
<% end %>
<% end %>
<span class="<%= responsive_show_mobile_classes %> …">
Page <%= current_page %> of <%= total_pages %>
</span>
RESPONSIVE_HIDE_MOBILE = "hidden sm:inline-flex" is concatenated onto buttons that already include inline-flex from BUTTON_BASE_CLASSES — no tw_merge. Current page + ellipsis stay visible; the mobile label is added on top.
NAV_CLASSES = "flex items-center gap-1"
WRAPPER_BASE_CLASSES = "flex items-center gap-4 flex-wrap"
ALIGNMENT_CLASSES = {
left: "justify-start",
center: "justify-center",
right: "justify-end",
between: "justify-between"
}
The numbered row is a flex child with default min-width: auto and no flex-wrap / max-w-full / min-w-0. It will not shrink below its content width.
The wrapper is a full-width flex container. Alignment moves the overflowing child as a block:
justify-start — extra width spills right (next / last page clipped).justify-center — extra width splits both sides (prev outside left; “Page X of Y” / next outside right).justify-end — extra width spills left (prev / early pages clipped).justify-between — info may wrap; the button row still overflows right.page_series below sm (current page + gaps included). Keep prev / “Page X of Y” / next only.tw_merge display utilities so hidden wins over inline-flex on the same node.min-w-0 max-w-full flex-wrap (or overflow-x-auto if a single row must stay).w-full min-w-0 so justify-* runs inside the parent, not past it.align:; assert no descendant overflows the nav box, and that inactive page links + ellipsis are not visible.<div class="hidden sm:contents"> <%# or per-item hidden sm:inline-flex, merged %>
<% page_series.each … %>
</div>
<span class="inline-flex sm:hidden">Page X of Y</span>
align: values.sm, numbered/full variants show prev + page label + next — not the numbered series.