Keyboard shortcut: Ctrl + K
Get started

Pagination

VPagination selects a page with buttons or links. It supports truncated ranges.

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vectis-ui'

const page = ref(1)
</script>

<template>
  <VPagination v-model="page" :length="8" />
</template>

Examples

Variants and tones

itemVariant styles other pages and controls. tone colours only the current page.

vue

ghost

outline

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const variants = ['ghost', 'outline'] as const
const tones = ['accent', 'neutral', 'danger'] as const

const page = ref(3)
</script>

<template>
  <div class="column">
    <div v-for="variant in variants" :key="variant" class="row">
      <VPagination
        v-for="tone in tones"
        :key="tone"
        v-model="page"
        :length="6"
        :item-variant="variant"
        :tone="tone"
        :label="`${variant}, ${tone}`"
      />
      <VTypography variant="caption" tone="muted">{{ variant }}</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-6);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

How the selection is drawn

selectedVariant styles the current page as solid, soft or ghost.

vue

solid

soft

ghost

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography, type PaginationSelectedVariant } from 'vectis-ui'

const variants: PaginationSelectedVariant[] = ['solid', 'soft', 'ghost']
const pages = ref<Record<string, number>>({ solid: 3, soft: 3, ghost: 3 })
</script>

<template>
  <div class="column">
    <div v-for="variant in variants" :key="variant" class="row">
      <VTypography variant="caption" tone="muted">{{ variant }}</VTypography>
      <VPagination
        v-model="pages[variant]"
        :length="6"
        :selected-variant="variant"
        item-variant="outline"
        :label="`Pages, ${variant}`"
      />
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-5);
}
.row {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-2);
}
</style>

Detached

detached separates the buttons. bordered adds dividers between joined buttons.

vue

Joined, the default

detached

bordered

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const joined = ref(3)
const detached = ref(3)
const bordered = ref(3)
</script>

<template>
  <div class="column">
    <div class="row">
      <VPagination v-model="joined" :length="6" item-variant="outline" label="Joined pages" />
      <VTypography variant="caption" tone="muted">Joined, the default</VTypography>
    </div>

    <div class="row">
      <VPagination
        v-model="detached"
        :length="6"
        detached
        item-variant="outline"
        label="Detached pages"
      />
      <VTypography variant="caption" tone="muted">detached</VTypography>
    </div>

    <div class="row">
      <VPagination
        v-model="bordered"
        :length="6"
        bordered
        item-variant="outline"
        label="Bordered pages"
      />
      <VTypography variant="caption" tone="muted">bordered</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

Elevated

elevated adds a shadow to the row, or to each button when detached.

vue

elevated

elevated, detached

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const joined = ref(3)
const detached = ref(3)
</script>

<template>
  <div class="column">
    <div class="row">
      <VPagination
        v-model="joined"
        :length="6"
        elevated
        item-variant="outline"
        label="Raised joined pages"
      />
      <VTypography variant="caption" tone="muted">elevated</VTypography>
    </div>

    <div class="row">
      <VPagination
        v-model="detached"
        :length="6"
        elevated
        detached
        item-variant="outline"
        label="Raised detached pages"
      />
      <VTypography variant="caption" tone="muted">elevated, detached</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-6);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

Sizes

size sets the button size.

vue

xs

sm

md

lg

xl

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const sizes = ['xs', 'sm', 'md', 'lg', 'xl'] as const

const page = ref(3)
</script>

<template>
  <div class="column">
    <div v-for="size in sizes" :key="size" class="row">
      <VPagination
        v-model="page"
        :length="6"
        :size="size"
        item-variant="outline"
        :label="`Pages, ${size}`"
      />
      <VTypography variant="caption" tone="muted">{{ size }}</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-4);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

Length

length is the total page count. Without totalVisible, all pages appear.

vue

length 4

length 12

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const short = ref(2)
const long = ref(7)
</script>

<template>
  <div class="column">
    <div class="row">
      <VPagination v-model="short" :length="4" item-variant="outline" label="Four pages" />
      <VTypography variant="caption" tone="muted">length 4</VTypography>
    </div>

    <div class="row">
      <VPagination v-model="long" :length="12" item-variant="outline" label="Twelve pages" />
      <VTypography variant="caption" tone="muted">length 12</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

Total visible

totalVisible caps page and ellipsis slots. From five slots, the first and last pages remain visible. Below five, consecutive pages surround the current one, down to the current page alone. At zero, only the controls remain.

vue

totalVisible 1

totalVisible 3

totalVisible 5

totalVisible 7

Page 1 of 20

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const page = ref(1)
</script>

<template>
  <div class="column">
    <div v-for="slots in [1, 3, 5, 7]" :key="slots" class="row">
      <VPagination
        v-model="page"
        :length="20"
        :total-visible="slots"
        item-variant="outline"
        :label="`Twenty pages in ${slots} slots`"
      />
      <VTypography variant="caption" tone="muted">totalVisible {{ slots }}</VTypography>
    </div>

    <VTypography variant="body-sm" tone="muted">Page {{ page }} of 20</VTypography>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

Previous and next

controls selects icons, text, both or neither. Controls disable when no reachable page remains in their direction.

vue

icon, the default

text

both

false, no controls at all

Icons and words of your own

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'
import { arrow_left_alt as arrowLeftAlt, arrow_right_alt as arrowRightAlt } from 'vectis-ui/icons'

const DISPLAYS = [
  { value: 'icon', caption: 'icon, the default' },
  { value: 'text', caption: 'text' },
  { value: 'both', caption: 'both' },
  { value: false, caption: 'false, no controls at all' },
] as const

const page = ref(3)
</script>

<template>
  <div class="column">
    <div v-for="display in DISPLAYS" :key="String(display.value)" class="row">
      <VPagination
        v-model="page"
        :length="6"
        :controls="display.value"
        item-variant="outline"
        :label="`Pages, controls ${display.caption}`"
      />
      <VTypography variant="caption" tone="muted">{{ display.caption }}</VTypography>
    </div>

    <div class="row">
      <VPagination
        v-model="page"
        :length="6"
        controls="both"
        :prev-icon="arrowLeftAlt"
        :next-icon="arrowRightAlt"
        prev-text="Newer"
        next-text="Older"
        item-variant="outline"
        label="Pages with wording of their own"
      />
      <VTypography variant="caption" tone="muted">Icons and words of your own</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

First and last

edgeControls adds controls leading to the first and last reachable pages, displayed as controls specifies.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vectis-ui'

const page = ref(5)
</script>

<template>
  <div class="column">
    <VPagination
      v-model="page"
      :length="20"
      :total-visible="7"
      edge-controls
      item-variant="outline"
      label="Pages with first and last controls"
    />
    <VPagination
      v-model="page"
      :length="20"
      :total-visible="7"
      edge-controls
      controls="both"
      item-variant="outline"
      label="Pages with first and last controls, with text"
    />
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
</style>

Unreachable pages

disabledPages accepts a page array or predicate. Controls skip those pages.

vue

A list. Now on page 1

A predicate. Now on page 1

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const listed = ref(1)
const predicate = ref(1)
</script>

<template>
  <div class="column">
    <div class="row">
      <VPagination
        v-model="listed"
        :length="10"
        :disabled-pages="[2, 3, 4]"
        controls="both"
        item-variant="outline"
        label="Pages 2 to 4 unavailable"
      />
      <VTypography variant="caption" tone="muted">A list. Now on page {{ listed }}</VTypography>
    </div>

    <div class="row">
      <VPagination
        v-model="predicate"
        :length="10"
        :disabled-pages="(page) => page % 2 === 0"
        controls="both"
        item-variant="outline"
        label="Even pages unavailable"
      />
      <VTypography variant="caption" tone="muted">
        A predicate. Now on page {{ predicate }}
      </VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

Provide href to render links. Handle navigate and call preventDefault() for router navigation. Modified clicks preserve native link behaviour without updating the model.

vue

Links to /app/products?page=3

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const page = ref(3)

const href = (n: number) => `/app/products?page=${n}`

// Cancel native navigation and pass the URL to your router.
function onNavigate(_n: number, event: MouseEvent) {
  event.preventDefault()
}
</script>

<template>
  <div class="row">
    <VPagination
      v-model="page"
      :length="12"
      :total-visible="7"
      :href="href"
      label="Products"
      @navigate="onNavigate"
    />
    <VTypography variant="caption" tone="muted">Links to {{ href(page) }}</VTypography>
  </div>
</template>

<style scoped>
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

States

disabled disables the entire row.

vue

The whole row switched off

On the first page

On the last page

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const page = ref(3)
const first = ref(1)
const last = ref(6)
</script>

<template>
  <div class="column">
    <div class="row">
      <VPagination
        v-model="page"
        :length="6"
        disabled
        controls="both"
        item-variant="outline"
        label="Pages unavailable"
      />
      <VTypography variant="caption" tone="muted">The whole row switched off</VTypography>
    </div>

    <div class="row">
      <VPagination
        v-model="first"
        :length="6"
        controls="both"
        item-variant="outline"
        label="On the first page"
      />
      <VTypography variant="caption" tone="muted">On the first page</VTypography>
    </div>

    <div class="row">
      <VPagination
        v-model="last"
        :length="6"
        controls="both"
        item-variant="outline"
        label="On the last page"
      />
      <VTypography variant="caption" tone="muted">On the last page</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-5);
}
</style>

Alignment

align positions the row within the available width.

vue

start

center

end

<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VTypography } from 'vectis-ui'

const aligns = ['start', 'center', 'end'] as const

const page = ref(3)
</script>

<template>
  <div class="column">
    <div v-for="align in aligns" :key="align" class="box">
      <VPagination
        v-model="page"
        :length="6"
        :align="align"
        item-variant="outline"
        :label="`Pages aligned ${align}`"
      />
      <VTypography variant="caption" tone="muted">{{ align }}</VTypography>
    </div>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-5);
}
.box {
  display: grid;
  gap: var(--vectis-space-2);
  padding: var(--vectis-space-3);
  border: 1px dashed var(--vectis-color-border);
  border-radius: var(--vectis-radius-surface);
}
</style>

API

Props

PropTypeDefault
lengthnumber1
Total page count.
totalVisiblenumbernone
Maximum page and ellipsis slots; 0 leaves the controls alone. Omitted shows every page.
detachedbooleanfalse
Separates page buttons.
borderedbooleanfalse
Adds dividers between joined buttons. Ignored when detached.
itemVariantPaginationItemVariant'ghost' | 'outline''outline'
Style of other pages and previous/next controls.
selectedVariantPaginationSelectedVariant'solid' | 'soft' | 'ghost''solid'
Style of the current page.
tonePaginationTone'accent' | 'neutral' | 'danger''accent'
Colour of the current page.
sizePaginationSize'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
Component size.
elevatedbooleanfalse
Adds a shadow to the row or detached buttons.
alignPaginationAlign'start' | 'center' | 'end''start'
Row alignment within the available width.
controlsPaginationControlsfalse | 'icon' | 'text' | 'both''icon'
Previous/next content: icons, text, both or false.
prevIconIconSourcechevron_left
Previous control icon.
nextIconIconSourcechevron_right
Next control icon.
prevTextstringnone
Previous control text and accessible name. Defaults to the dictionary.
nextTextstringnone
Next control text and accessible name. Defaults to the dictionary.
edgeControlsbooleanfalse
Adds first and last page controls, displayed as controls specifies.
firstIconIconSourcefirst_page
First page control icon.
lastIconIconSourcelast_page
Last page control icon.
firstTextstringnone
First page control text and accessible name. Defaults to the dictionary.
lastTextstringnone
Last page control text and accessible name. Defaults to the dictionary.
disabledbooleanfalse
Disables interaction.
disabledPagesPaginationMatchernone
Unavailable pages as an array or predicate. Controls skip them.
labelstringnone
Accessible navigation name. Defaults to the dictionary.
pageLabel(page: number) => stringnone
Function providing an accessible name for each page number. Defaults to the dictionary.
href(page: number) => stringnone
Function mapping a page to its URL. Renders pages and controls as links.
v-modelnumber1
Current page, starting at 1.

Events

EventType
navigate[page: number, event: MouseEvent]
Page activation, before the model update. Receives the page and click event; call preventDefault() for routing. Modified clicks do not emit it.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender
export type PaginationMatcher = number[] | ((page: number) => boolean)