Skip to content

Pagination

A neo-brutalist style pagination component built with a built-in pagination range calculation algorithm. Supports responsive pagination range computation (automatic ellipsis display), first/last page quick navigation, configurable sibling count (siblingCount) to control the visible range, multiple variants and size options, full accessibility support (aria-label, aria-current), and clickable ellipsis for custom page-jump interactions.

Demo

Preview

基础用法

变体:默认 / 圆角 / 极简

尺寸:小 / 默认 / 大

siblingCount(相邻页码数)

showFirstLast(首页/末页按钮)

showPageNumbers(页码显示模式)

自定义布局与快速跳转(Jumper)

通过配置 layout 属性,可以自由排列:总条数(total)、每页条数(sizes)、上一页(prev)、页码(pager)、下一页(next)和快速跳转(jumper)。

可点击省略号(jump 事件)

点击省略号 ••• 触发 jump 事件,弹出输入框直接跳转到目标页码。

Installation

pnpm dlx brutx-vue@latest add pagination

Usage

vue
<script setup>
import { ref } from 'vue'
import { Pagination } from 'brutx-ui-vue'

const currentPage = ref(1)
const totalPages = 10
</script>

<template>
    <Pagination
        v-model="currentPage"
        :total-pages="totalPages"
    />
</template>

With Full Options

vue
<script setup>
import { ref } from 'vue'
import { Pagination } from 'brutx-ui-vue'

const currentPage = ref(1)
</script>

<template>
    <Pagination
        v-model="currentPage"
        :total-pages="50"
        :sibling-count="2"
        :show-first-last="true"
        :show-page-numbers="true"
        variant="default"
        size="default"
    />
</template>

Custom Layout & Quick Jumper

You can arrange and display different functional blocks by configuring the layout prop, including: total items count (total), page size selector (sizes), previous page (prev), page numbers (pager), next page (next), and quick jumper (jumper). The default value is 'sizes, prev, pager, next, jumper, total'. In the jumper input field, you can input a target page number and press Enter to jump.

vue
<script setup>
import { ref } from 'vue'
import { Pagination } from 'brutx-ui-vue'

const currentPage = ref(1)
const pageSize = ref(10)
</script>

<template>
    <Pagination
        v-model="currentPage"
        v-model:page-size="pageSize"
        :total="100"
        layout="total, sizes, prev, pager, next, jumper"
    />
</template>

Without Page Numbers

When showPageNumbers is set to false, the component displays a counter showing the current page and total pages (e.g., "3 / 10") instead of page number buttons.

vue
<script setup>
import { ref } from 'vue'
import { Pagination } from 'brutx-ui-vue'

const currentPage = ref(1)
</script>

<template>
    <Pagination
        v-model="currentPage"
        :total-pages="10"
        :show-page-numbers="false"
    />
</template>

Clickable Ellipsis

When the total page count is large, the pagination range uses ellipsis ... to represent collapsed page numbers. The ellipsis is a clickable <button> element (with aria-label="Jump pages" for accessibility), which triggers the jump event (no payload) when clicked. Developers can implement custom page-jump interactions in this event, such as showing an input dialog for the user to enter a target page number.

vue
<script setup>
import { ref } from 'vue'
import { Pagination } from 'brutx-ui-vue'

const currentPage = ref(1)

function handleJump() {
    const input = window.prompt('Jump to which page?')
    if (input !== null) {
        const page = Number(input)
        if (Number.isFinite(page)) {
            currentPage.value = page
        }
    }
}
</script>

<template>
    <Pagination
        v-model="currentPage"
        :total-pages="50"
        :sibling-count="1"
        @jump="handleJump"
    />
</template>

Variants

VariantDescription
defaultStandard button style
roundedButtons use --brutal-radius border radius
minimalButtons without border and shadow

Sizes

SizeButton HeightGapIcon Size
smh-8gap-1h-3 w-3
defaulth-10gap-2h-4 w-4
lgh-12gap-3h-5 w-5

Props

PropTypeDefaultDescription
modelValuenumber— (required)Current page number, supports v-model two-way binding
totalPagesnumberTotal number of pages (mutually exclusive with total + pageSize)
totalnumberTotal number of items
pageSizenumber10Number of items per page
pageSizesnumber[][10, 20, 50, 100]Page size options
layoutstring'sizes, prev, pager, next, jumper, total'Custom layout (comma-separated: total, sizes, prev, pager, next, jumper)
disabledbooleanfalseWhether disabled
backgroundbooleanfalseWhether page buttons have background color
hideOnSinglePagebooleanfalseWhether to hide when there is only one page
siblingCountnumber1Number of sibling pages displayed on each side of the current page
showFirstLastbooleantrueWhether to show first/last page buttons
showPageNumbersbooleantrueWhether to show page number buttons; when false, displays a page counter instead
variant'default' | 'rounded' | 'minimal''default'Component variant style
size'sm' | 'default' | 'lg''default'Component size
classstringCustom CSS class name, merged onto the root <nav> element

Events

EventPayloadDescription
update:modelValuepage: numberTriggered when the page number changes, used for v-model binding
update:pageSizesize: numberTriggered when the page size changes
jumpTriggered when the ellipsis ... button is clicked, used for custom page-jump interactions

Accessibility

  • ARIA Attributes: The root element uses a <nav> tag with role="navigation" and aria-label attributes; page number buttons use the format aria-label="Go to page X"; the current page button is identified with aria-current="page"
  • Focus Management: Navigation buttons use semantic labels (first page, previous page, next page, last page); disabled states use the disabled attribute with corresponding styles

Brute force builds.