Skip to content
API 风格:

Pagination ​

Page navigation: previous/next, page window with ellipses, size changer, jumper and total count. The window-shrinking algorithm lives in core as pure functions.

Basic Usage ​

Basic Usage
vue
<script setup lang="ts">
</script>

<template>
  <LhPagination :total="120" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhPagination :total="120" />
</template>

Total and Size Changer ​

Total and Size Changer
vue
<script setup lang="ts">
</script>

<template>
  <LhPagination :total="480" show-total show-size-changer />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhPagination :total="480" show-total show-size-changer />
</template>

Jumper ​

Jumper
vue
<script setup lang="ts">
</script>

<template>
  <LhPagination :total="480" show-total show-jumper />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhPagination :total="480" show-total show-jumper />
</template>

Simple Mode ​

Simple Mode
vue
<script setup lang="ts">
</script>

<template>
  <LhPagination :total="480" simple show-jumper />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhPagination :total="480" simple show-jumper />
</template>

Controlled Usage ​

Controlled Usage

Current page: 2

vue
<script setup lang="ts">
import { ref } from 'vue'
const page = ref(2)
const pageSize = ref(20)
</script>

<template>
  <LhPagination v-model:current="page" :total="95" />
</template>
vue
<script>
export default {
  data() {
    return { page: 2, pageSize: 20 }
  },
}
</script>

<template>
  <LhPagination v-model:current="page" :total="95" />
</template>

Page size and disabled ​

v-model:page-size controls the page size and page-sizes customizes the options; disabled disables the whole pagination.

Page size & disabled

Page size: 20

vue
<script setup lang="ts">
import { ref } from 'vue'
const pageSize = ref(20)
</script>

<template>
  <LhPagination
    v-model:page-size="pageSize"
    :total="480"
    show-size-changer
    :page-sizes="[10, 20, 50, 100]"
  />
  <LhPagination :total="480" disabled />
</template>
vue
<script>
export default {
  data() {
    return { pageSize: 20 }
  },
}
</script>

<template>
  <LhPagination
    v-model:page-size="pageSize"
    :total="480"
    show-size-changer
    :page-sizes="[10, 20, 50, 100]"
  />
  <LhPagination :total="480" disabled />
</template>

Pagination API ​

Props ​

PropDescriptionTypeDefault
totalTotal items (required)number—
pageSizeItems per pagenumber10
currentCurrent page (v-model:current)number—
pageSizesSize optionsnumber[]() => [10, 20, 30, 40]
showTotalShow the total countbooleanfalse
showSizeChangerShow the size changerbooleanfalse
showJumperShow the jumper inputbooleanfalse
simpleCompact modebooleanfalse
disabledDisable everythingbooleanfalse
sxsx quick-layout propsLhSxProps—

Events ​

EventDescriptionCallback
update:currentCurrent page changed (v-model)(page: number)
update:pageSizePage size changed (v-model:pageSize)(size: number)
changePage changed(page: number)
size-changePage size changed(size: number)

Accessibility ​

  • The root is <nav aria-label="pagination">
  • The active page button gets aria-current="page"
  • Every page button and the prev/next buttons carry individual aria-labels (from the pagination.page / prev / next locale messages); the bare "‹" "›" glyphs are aria-hidden
  • The jumper input has a real <label> (from the pagination.goto locale message)
  • The size changer is a native <select> with an aria-label (from pagination.sizeChangerLabel)
  • Ellipses are non-interactive aria-hidden elements and stay out of the keyboard flow

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/pagination/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhPaginationProps
ts
export interface LhPaginationProps {
  total: number
  pageSize?: number
  current?: number
  pageSizes?: number[]
  showTotal?: boolean
  showSizeChanger?: boolean
  showJumper?: boolean
  simple?: boolean
  disabled?: boolean
  sx?: LhSxProps
}

Beauty of tradition, foundation of code