Paginators
Navigate between multiple pages of content.
import { Paginator } from '@skeletonlabs/skeleton';Demo
Numeric Row
Use showNumerals to replace the text information with a row of buttons that allow you to quickly navigate pages. We recommend a small maxNumerals amount if you plan to support mobile devices with limited screen real estate.
Client-Side Pagination
Once your paginator component is setup you'll need to subdivide your local source content. This can be accomplished using Svelte's reactive properties paired with the JavaScript slice method.
$: paginatedSource = source.slice(
paginationSettings.page * paginationSettings.limit,
paginationSettings.page * paginationSettings.limit + paginationSettings.limit
);<ul>
{#each paginatedSource as row}
<li>{row}</li>
{/each}
</ul>Or combine with the Table component.
let tableHeaders: string[] = ['Positions', 'Name', 'Weight', 'Symbol'];<Table source={{ head: tableHeaders, body: paginatedSource }} />Server-Side Pagination
Use the page and amount events to notify your server of pagination updates.
function onPageChange(e: CustomEvent): void {
console.log('event:page', e.detail);
}
function onAmountChange(e: CustomEvent): void {
console.log('event:amount', e.detail);
}<Paginator ... on:page={onPageChange} on:amount={onAmountChange}></Paginator>Handling Reactivity
Use the following technique if you wish to update pagination data in a reactive manner. Make sure to update paginationSettings directly, as updating a reference to source will not trigger the reactivity.
let paginationSettings = {
page: 0,
limit: 5,
size: source.length,
amounts: [1, 2, 5, 10],
} satisfies PaginationSettings;
$: paginationSettings.size = source.length;See Also
Utilize a data-driven model to create simple presentational tables.