vael-ui v0.5.7

Data display

Layout

Pagination

Page-number controls that split a long list or table across pages. Use it when people need to reach a specific page.

Install

import { Pagination } from 'vael-ui'

Playground

Usage
<script setup lang="ts">
import { Pagination } from 'vael-ui'
</script>

<template>
  <Pagination :total="132" />
</template>

Props

NameTypeDefaultDescription
totalRequirednumberTotal item count across all pages, not the current page's row count.
pageSizeOptionsnumber[]Page-size <Select> options. Omit it to hide the dropdown.
siblingCountnumber1Page-number buttons to show on each side of the current page before an ellipsis.
motionPaginationMotiontrueHow it moves: its appearance, button by button ({ initial: { button: { opacity: 0, y: 4 } }, stagger: 0.03 }), over root, button and the current page's indicator. spring retimes the indicator; move hands its moves to your own animation. false skips the indicator's built-in sliding; animate the exposed indicatorEl and labelsEl yourself.
uiPartial<Record<'root' | 'list' | 'button' | 'ellipsis' | 'sizeSelect', UiPartValue>>Class and style overrides for each part.
pagenumber1Current page, 1-based.
pageSizenumber10Rows per page. Picking a size from the dropdown resets page to 1.

Events

NameTypeDescription
update:page(value: number)Fires when page changes (v-model:page).
update:pageSize(value: number)Fires when pageSize changes (v-model:pageSize).

Slots

No slots.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
listElHTMLElement | nullThe page-number list.
indicatorElHTMLElement | nullThe sliding highlight behind the current page.
highlightElHTMLElement | nullThe hover and keyboard highlight, sliding between buttons. With motion: false it moves at once, for your own animation.
labelsElHTMLElement | nullThe page numbers in the contrast color, clipped to the indicator.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Pagination: its appearance, and how the current-page indicator moves.

<Pagination
  :motion="{ initial: { root: { opacity: 0, y: 4 } } }"
/>
NameTypeDescription
initialexitrootbuttonindicatorSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
move(parts, context) => animationMoves its sliding indicator. A spring retimes it, and a move hook animates it with your own library, starting from context.from.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

KeyAction
TabShiftTabMoves between the page buttons and the page size Select.
EnterSpaceGoes to the focused page, or to the first, previous, next or last page.
  • The root is a <nav> named “Pagination”, and the buttons sit in a <ul>.
  • The current page button has aria-current="page", and each page button is named “Page 3”, “Page 4” and so on.
  • The first, previous, next and last buttons have their own names. At either end they set aria-disabled, so they keep focus.
  • The ellipsis, the indicator and the hover highlight are aria-hidden. The page size Select is named “Rows per page”.