usePagination
Client-side pagination: offsets, ranges and visible page numbers for tables and lists. Options take numbers, refs or getters, and the page is pulled back the moment a filter shrinks the total under it.
Install: pnpm add-composable usePagination
Paginated list
Slice an array and control navigation.
API
total(MaybeRefOrGetter<number>): Option. Item count; a getter like () => rows.value.length follows a filtered list.pageSize(MaybeRefOrGetter<number>): Option. Items per page. Changing it goes back to page 1.initialPage(number): Option. Starting page, clamped to the pages that exist.maxVisiblePages(MaybeRefOrGetter<number>): Option. How many page buttons visiblePages returns.page(Ref<number>): Current page (1-based). Never past totalPages, even right after the total shrinks.totalPages(ComputedRef<number>): At least 1, so an empty list is page 1 of 1.range(ComputedRef<{ start, end, total }>): For "21–25 of 25"; start is 0 when the list is empty.visiblePages(ComputedRef<number[]>): Page numbers for a pagination bar, centred on the current page.isFirst, isLast(ComputedRef<boolean>): For disabling Previous and Next.goTo, next, prev, first, last(Function): Navigation. goTo clamps.paginate(<T>(items: readonly T[]) => T[]): Slices an array to the current page.