Skip to content

Pagination - Vant 4

Pagination

Intro

When the amount of data is too much, use pagination to separate the data, and load only one page at a time.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

js
import { createApp } from'vue'; import { Pagination } from'vant'; const app = createApp(); app.use(Pagination);

Usage

Basic Usage

html
js
import { ref } from'vue'; exportdefault { setup() { const currentPage = ref(1); return { currentPage }; }, };

Simple mode

html

Show ellipses

html

Custom Button

html

API

Props

AttributeDescriptionTypeDefault
v-modelCurrent page numbernumber-
modeMode, can be set to simple``multistringmulti
prev-textPrevious textstringPrevious
next-textNext textstringNext
total-itemsTotal items*numberstring*
items-per-pageItem number per page*numberstring*
page-countThe total number of pages, if not set, will be calculated based on total-items and items-per-page*numberstring*
show-page-sizeCount of page size to show*numberstring*
force-ellipsesWhether to show ellipsesbooleanfalse
show-prev-button v4.2.1Whether to show prev buttonbooleantrue
show-next-button v4.2.1Whether to show next buttonbooleantrue

Events

EventDescriptionArguments
changeEmitted when current page changed-

Slots

NameDescriptionSlotProps
pageCustom pagination item{ number: number, text: string, active: boolean }
prev-textCustom prev text-
next-textCustom next text-

Types

The component exports the following type definitions:

ts
importtype { PaginationMode, PaginationProps } from'vant';

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-pagination-height40px-
--van-pagination-font-sizevar(--van-font-size-md)-
--van-pagination-item-width36px-
--van-pagination-item-default-colorvar(--van-primary-color)-
--van-pagination-item-disabled-colorvar(--van-gray-7)-
--van-pagination-item-disabled-backgroundvar(--van-background)-
--van-pagination-backgroundvar(--van-background-2)-
--van-pagination-desc-colorvar(--van-gray-7)-
--van-pagination-disabled-opacityvar(--van-disabled-opacity)-

Enterprise-level mobile solution based on Vant