Pagination
Navigate a result set by page using state or destinations.
Anatomy#
Usage#
Use Pagination when a result set has a known page count. The application owns data fetching and the mapping from page numbers to URLs or controlled state. Do not use Pagination for a wizard; use Stepper for a fixed sequence of steps.
Current page#
Use page with onPageChange for controlled navigation, or defaultPage to start uncontrolled.
total is the number of records, not the page count; the component derives the page count,
ceil(total / pageSize), from pageSize. The page count is at least 1. A page outside that range
is clamped for display, so reset the page when pageSize changes. onPageChange also fires in
controlled mode, so write the value back to page.
Page window and controls#
siblingCount (default 2) sets how many page numbers show on each side of the current page. The
first and last pages always show, with ellipses for skipped ranges. Every page shows without
ellipses when 2 * siblingCount + 5 reaches the page count. Set controls={false} to hide Previous
and Next. prevText and nextText add visible text to those controls; their accessible names still
come from translations.
Rendering links#
Use getPageHref(page) by itself to render page controls as anchors. The current page stays a button.
For router integration, use itemRender for numbered items and controlRender for Previous/Next; these
props are independent and getPageHref still only generates the destination. Clicking a link also calls
onPageChange. Previous on the first page and Next on the last page remain disabled buttons even
when controlRender is set, and disabled turns every control into a disabled button.
itemRender and controlRender take a component that receives native anchor props
(PaginationT.ItemRenderProps); spread them onto your router link. The current page has no
href, so handle that case in the component.
Keyboard interaction#
Pagination adds no arrow-key navigation across controls. Each page control keeps the keyboard semantics of the button or link it renders. A visually hidden live region announces the current page after each change.
Examples#
Browse a result set#
Drive the current page from local state and show which page is active.
Keep the page in the URL#
Render numbered items and Previous/Next through Solid Router. Destinations such as
/pagination?page=2 stay in sync with the current page.
Page a customer table#
Slice the visible rows from application state. Previous and Next stay labeled.
Change results per page#
Reset to page 1 when the page size changes so the requested page stays inside the new count.
API Reference#
Attributes#
data-disableddata-loadingdata-textdata-currentdata-ellipsisProps#
Props for the Pagination component. Renders a <nav> element by default.