Use the default-page prop or the v-model:page directive to control the current page.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" :total="100" />
</template>
Button to display the pages, use color, variant and size props to style them.Use the total prop to set the total number of items in the list.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" :total="100" />
</template>
Use the items-per-page prop to set the number of items per page. Defaults to 10.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" :items-per-page="20" :total="100" />
</template>
Use the sibling-count prop to set the number of siblings to show. Defaults to 2.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" :sibling-count="1" :total="100" />
</template>
Use the show-edges prop to always show the ellipsis, first and last pages. Defaults to false.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" show-edges :sibling-count="1" :total="100" />
</template>
Use the show-controls prop to show the first, prev, next and last buttons. Defaults to true.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" :show-controls="false" show-edges :total="100" />
</template>
Use the color prop to set the color of the inactive controls. Defaults to neutral.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" color="primary" :total="100" />
</template>
Use the variant prop to set the variant of the inactive controls. Defaults to outline.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" color="neutral" variant="subtle" :total="100" />
</template>
Use the active-color prop to set the color of the active control. Defaults to primary.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" active-color="neutral" :total="100" />
</template>
Use the active-variant prop to set the variant of the active control. Defaults to solid.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" active-color="primary" active-variant="subtle" :total="100" />
</template>
Use the size prop to set the size of the controls. Defaults to md.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" size="xl" :total="100" />
</template>
Use the disabled prop to disable the pagination controls.
<script setup lang="ts">
const page = ref(5)
</script>
<template>
<UPagination v-model:page="page" :total="100" disabled />
</template>
Use the to prop to transform buttons into links. Pass a function that receives the page number and returns a route destination.
<script setup lang="ts">
const page = ref(5)
function to(page: number) {
return {
query: {
page
},
hash: '#with-links'
}
}
</script>
<template>
<UPagination v-model:page="page" :total="100" :to="to" :sibling-count="1" show-edges />
</template>
#with-links hash to avoid going to the top of the page.| Prop | Default | Type |
|---|---|---|
as | 'div' | anyThe element or component this component should render as. |
firstIcon | appConfig.ui.icons.chevronDoubleLeft | string | objectThe icon to use for the first page control. |
prevIcon | appConfig.ui.icons.chevronLeft | string | objectThe icon to use for the previous page control. |
nextIcon | appConfig.ui.icons.chevronRight | string | objectThe icon to use for the next page control. |
lastIcon | appConfig.ui.icons.chevronDoubleRight | string | objectThe icon to use for the last page control. |
ellipsisIcon | appConfig.ui.icons.ellipsis | string | objectThe icon to use for the ellipsis control. |
color | 'neutral' | "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning"The color of the pagination controls. |
variant | 'outline' | "outline" | "solid" | "soft" | "subtle" | "ghost" | "link"The variant of the pagination controls. |
activeColor | 'primary' | "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning"The color of the active pagination control. |
activeVariant | 'solid' | "outline" | "solid" | "soft" | "subtle" | "ghost" | "link"The variant of the active pagination control. |
showControls | true | boolean Whether to show the first, previous, next, and last controls. |
size | "xs" | "sm" | "md" | "lg" | "xl" | |
to | (page: number): string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric A function to render page controls as links. | |
defaultPage | numberThe value of the page that should be active when initially rendered. Use when you do not need to control the value state. | |
disabled | boolean When | |
itemsPerPage | 10 | numberNumber of items per page |
page | numberThe controlled value of the current page. Can be binded as | |
showEdges | false | boolean When |
siblingCount | 2 | numberNumber of sibling should be shown around the current page |
total | 0 | numberNumber of items in your list |
ui | { root?: ClassNameValue; list?: ClassNameValue; ellipsis?: ClassNameValue; label?: ClassNameValue; first?: ClassNameValue; prev?: ClassNameValue; item?: ClassNameValue; next?: ClassNameValue; last?: ClassNameValue; } |
| Slot | Type |
|---|---|
first | {} |
prev | {} |
next | {} |
last | {} |
ellipsis | { ui: object; } |
item | { page: number; pageCount: number; item: { type: "ellipsis"; } | { type: "page"; value: number; }; index: number; } |
| Event | Type |
|---|---|
update:page | [value: number] |
export default defineAppConfig({
ui: {
pagination: {
slots: {
root: '',
list: 'flex items-center gap-1',
ellipsis: 'pointer-events-none',
label: 'min-w-5 text-center',
first: '',
prev: '',
item: '',
next: '',
last: ''
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
pagination: {
slots: {
root: '',
list: 'flex items-center gap-1',
ellipsis: 'pointer-events-none',
label: 'min-w-5 text-center',
first: '',
prev: '',
item: '',
next: '',
last: ''
}
}
}
})
]
})