Page Size Selector

A controlled rows-per-page selector for TanStack Table pagination.

Pass the current pageSize and a setPageSize callback. Use options to customize the available sizes.

Rows per page

Showing 10 rows per page

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/page-size-selector.json

Usage

Keep the TanStack-specific pagination logic in the parent and pass only the current value and setter to the selector.

usage.svelte

Props

Page size selector props

NameTypeDefaultDescription
pageSizenumberrequiredThe currently selected number of rows per page.
optionsnumber[][5, 10, 25, 50]Page sizes displayed in the select menu.
setPageSize(pageSize: number) => voidrequiredCalled with the selected page size. Update your table or other pagination state here.
classstring""Optional classes for the root wrapper.