A reusable, flexible pagination component for the SolidStart frontend that supports both offset-based and cursor-based pagination.
Overview
The <Pagination> component exposes two distinct modes via the type prop:
type="offset": Traditional numbered pagination with ellipsis support (1, 2, ..., 9, 10). Ideal for admin panels, reports, and when users need to jump to arbitrary pages.
type="cursor": Compact navigation for infinite scroll or real-time datasets. Shows simple Previous/Next buttons. Ideal for chat logs, feeds, and highly dynamic lists where offset skipping is inefficient or inaccurate.
Usage
Props Reference
Ellipsis and siblingCount
The type="offset" component automatically inserts ellipsis (...) when there are large gaps between pages. The siblingCount prop controls how many page numbers appear directly adjacent to the active page.
For example, with totalPages={10} and siblingCount={1}:
- On page 1:
1, 2, ..., 10
- On page 5:
1, ..., 4, 5, 6, ..., 10
- On page 9:
1, ..., 8, 9, 10
If the gap between numbers is exactly 1 (e.g. 1, 2, 3, 4, ..., 7), no ellipsis is rendered between them.
Important Considerations
Page Size Changes in Cursor Mode
When using type="cursor" alongside onPageSizeChange, you must reset your cursor state whenever the page size is altered.Because cursor tokens point to specific boundaries within the dataset, changing the limit (page size) invalidates the existing cursor tokens.
Theme Support
theme="auto": Relies on Tailwind’s dark: classes. The component switches to dark mode if the parent <html> element has the dark class, or via prefers-color-scheme.
theme="dark": The component forces the dark theme locally. Useful for embedding the pagination in dark-only sections of the UI, overriding the global theme.
Types
The UI component aligns with the canonical PaginationMeta interface defined in the core package: