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#
page,defaultPage, andonPageChange: usepagewithonPageChangefor controlled navigation, ordefaultPageto start uncontrolled.onPageChangealso fires in controlled mode, so write the value back topage.totalandpageSize:totalis the record count (not the page count).Paginationderives the page count asMath.max(1, Math.ceil(total / pageSize)).- Clamping: a
pageoutside the derived range is clamped for display, so resetpagewhenpageSizechanges.
Page window and controls#
siblingCount(default2): sets how many page numbers appear on each side of the current page. The first and last pages always render, with ellipses for skipped ranges; every page shows without ellipses when2 * siblingCount + 5reaches the page count.controls: setcontrols={false}to hide the Previous and Next buttons.prevTextandnextText: add visible text to the Previous and Next controls (hidden below thesmbreakpoint) and replacetranslations.prevandtranslations.nextas their accessible names.
Rendering links#
getPageHref(page): renders numbered page controls and available Previous/Next controls as<a>elements with the returnedhref. Clicking a link still callsonPageChange.itemRenderandcontrolRender: accept a component receiving native anchor props (PaginationT.ItemRenderProps) for router integration on numbered items and Previous/Next controls respectively. Spread the received props onto your router link.- Button fallbacks: the current page has no
hrefand stays a button (handle missinghrefinitemRender). Previous on the first page, Next on the last page, and all controls whendisabledis set render as disabled buttons even whencontrolRenderis provided.
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#
Basic#
Drive the current page from local state and show which page is active.
Router links#
Render numbered items and Previous/Next through Solid Router. Destinations such as
/pagination?page=2 stay in sync with the current page.
Controlled#
Slice the visible rows from application state. Previous and Next stay labeled.
Page size#
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.