Skip to main content
Vuetify0 is now a release candidate!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

createPagination

A lightweight composable for managing pagination state with navigation methods and computed visible page items.

Usage

The createPagination composable provides reactive pagination state management with navigation methods and automatic computation of visible page items with ellipsis support.

ts
import { ref } from 'vue'
import { createPagination } from '@vuetify/v0'

const pagination = createPagination({
  size: 200, // Total items
  itemsPerPage: 10,
  visible: 5,
})

console.log(pagination.pages) // 20 (200 items / 10 per page)
console.log(pagination.items.value)
// [
//   { type: 'page', value: 1 },
//   { type: 'page', value: 2 },
//   { type: 'page', value: 3 },
//   { type: 'ellipsis', value: '…' },
//   { type: 'page', value: 20 }
// ]

Context / DI

Use createPaginationContext to share a pagination instance across a component tree:

ts
import { createPaginationContext } from '@vuetify/v0'

export const [usePagination, providePagination, pagination] =
  createPaginationContext({ size: 100, itemsPerPage: 10 })

// In parent component
providePagination()

// In child component
const pagination = usePagination()
pagination.next()

Architecture

createPagination computes page state and navigation:

Pagination Flow

Use controls to zoom and pan. Click outside or press Escape to close.

Pagination Flow

Reactivity

Property/MethodReactiveNotes
pageWritableComputedRef, auto-clamps when total pages shrinks
pagesTotal page count, computed from size / itemsPerPage
itemsComputed array of PaginationTicket — each is { type: 'page', value: number } or { type: 'ellipsis', value: string }
pageStartComputed, start index for current page
pageStopComputed, end index for current page
isFirstComputed, true when on first page
isLastComputed, true when on last page
itemsPerPageGetter — current items per page (reflects option)
sizeGetter — total item count (reflects option)
ellipsisGetter — the ellipsis string or false when disabled
select(page)-Navigate to a specific page number
next()-Go to next page (no-op if already last)
prev()-Go to previous page (no-op if already first)
first()-Jump to page 1
last()-Jump to final page
Tip

v-model support Pass a ref as the page option to enable two-way binding with your component’s page state.

Examples

Paginated List

A 47-row employee directory split into pages, with a rows-per-page selector, First / Prev / numbered pages / Next / Last controls, and a live “showing X–Y of Z” readout. The composable owns the dataset and pagination math; the table component is purely presentational; the entry wires the two together and renders the status line.

The composable creates the instance once with a reactive itemsPerPage — a shallowRef passed straight into the options, so changing rows-per-page recomputes pages, items, pageStart, and pageStop automatically. The visible slice is a single computed that reads pageStart.value and pageStop.value and calls Array.slice — no adapter, no data table, just the two index getters. This is the canonical pattern for paginating a plain in-memory array: createPagination owns the math, your computed owns the slice, and resize resets to the first page after a size change.

The page-button strip iterates pagination.items.value, which returns PaginationTicket[] — each is either { type: 'page', value: number } or { type: 'ellipsis', value: '…' }. The template branches on item.type and calls pagination.select(item.value) on click, while First / Prev / Next / Last bind their disabled prop to isFirst.value or isLast.value and call the matching navigation method directly.

Reach for this standalone composable when you already have a full in-memory array and only need page navigation — no sorting or filtering required. For a full data pipeline with sorting, filtering, and server-side support, see createDataTable. For the pre-built Pagination component that wraps this composable, see Pagination.

FileRole
usePaginatedList.tsOwns the dataset, the reactive page size, the pagination instance, and the visible-slice computed
PaginatedTable.vuePresentational table: renders rows, the rows-per-page selector, and the navigation controls
paginated-list.vueEntry — calls the composable, renders the table, and shows the range readout
Rows per page
1Employee 1
Design
2Employee 2
Engineering
3Employee 3
Marketing
4Employee 4
Sales
5Employee 5
Design
6Employee 6
Engineering
...

Showing 1–6 of 47 · Page 1 of 8

FAQ

Discord
Need help? Join our community for support and discussions ↗

API Reference

The following API details are for the createPagination composable.
Was this page helpful?

Ctrl+/