Using basic example found at https://tanstack.com/table/v8/docs/examples/svelte/basic as a starting point, make the following changes to enable basic pagination:
<script>
import {
...
getPaginationRowModel, // Import the pagination model
} from @tanstack/svelte-table ;
...
const options = writable({
...
getPaginationRowModel: getPaginationRowModel(), // Enable pagination
autoResetPageIndex: true, // Automatically update pagination when data or page size changes
});
let pageSize = 10; // number of rows to show
$table.setPageSize(pageSize);
</script>
<table>
<!-- No need to edit table code/html - the rows shown/hidden will be handled by svelte-table -->
</table>
<!-- Add buttons to control page index -->
<button
on:click{() => $table.previousPage()}
disabled={!$table.getCanPreviousPage()}
>
Prev
</button>
<button
on:click{() => $table.nextPage()}
disabled={!$table.getCanNextPage()}
>
Next
</button>