Pagination Examples
The examples below assume that you have imported the component and set up the theme.
Basic
Let users move between the pages of a long list. total sets the page count, and page sets the current page.
--first--last
<div class="pagination-basic"> <sv-pagination aria-label="Search results pages" page="5" total="20"></sv-pagination></div>
<style> .pagination-basic { display: grid; place-items: center; container-type: inline-size; }</style>Narrow Spaces
Keep the pagination on one line in a narrow space, like a phone screen or a sidebar. A container query hides ::part(list) and shows ::part(summary).
Drag the handle on the edge of the example to narrow it.
<div class="pagination-narrow"> <sv-pagination aria-label="Search results pages" page="5" total="20"></sv-pagination></div>
<style> .pagination-narrow { display: grid; place-items: center; container-type: inline-size;
@container (width < 25rem) { sv-pagination::part(list) { display: none; }
sv-pagination::part(summary) { display: block; } } }</style>Custom Labels
Show text in place of the previous and next icons. Content in the previous and next slots replaces the default icon and label.
<div class="pagination-labels"> <sv-pagination aria-label="Search results pages" page="5" total="20"> <span slot="previous">Previous</span> <span slot="next">Next</span> </sv-pagination></div>
<style> .pagination-labels { display: grid; place-items: center; container-type: inline-size;
sv-pagination::part(previous), sv-pagination::part(next) { min-inline-size: 6em; }
@container (width < 30rem) { sv-pagination::part(list) { display: none; }
sv-pagination::part(summary) { display: block; } } }</style>