Pagination
Let users move through pages of results with a row of page numbers between previous and next arrows.
Installation
Usage
[(page)]two-way binds the current page. Pages count from1.- Tapping a number goes to that page. The arrows step one page back or forward, and dim at the first and last page.
- The first and last pages always show. Around the current page,
siblingCountpages show on each side, and...fills the gaps. - With
5 + 2 × siblingCountpages or fewer, every page shows and there are no gaps.
Show the current page's items
Derive the visible slice from the page signal with computed(). It updates whenever the user changes page.
More neighbors
siblingCount sets how many pages show on each side of the current one. Fewer fit a narrow screen better.
React to a change
Listen to pageChange to run code when the user changes page. It fires inside the tap, so changing signals there is safe, but wrap router navigation in setTimeout (see the setTimeout rule).
API
UiPagination
The component doesn't clamp page. If you set it yourself, keep it between 1 and totalPages.
Related
- List: infinite scroll instead of pages
- Empty State: what to show when there are no results
