Navegação
VPagination
Controle de navegação página a página. Divide grandes volumes em páginas discretas com variantes default, compact, ellipsis e seletor de page size.
<script setup lang="ts">
import { VPagination } from 'vueui-nova-kit'
</script>Uso
<script setup lang="ts">
</script>
<template>
</template>Playground
Os controles abaixo são gerados a partir das props declaradas em VPagination.types.ts; o código acompanha cada mudança.
Exemplos
Variantes, tamanhos e estados, extraídos das stories da biblioteca.
Default
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(3)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'default',
modelValue: 3
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>Ellipsis
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(9)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'ellipsis',
modelValue: 9
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>Compact
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(3)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'compact',
modelValue: 3
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>With Page Size
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(3)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'default',
modelValue: 3,
showPageSize: true,
showResultCount: true
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>Sizes
Variação Tamanhos. Interativo: o estado é mantido na própria story (v-model).
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(3)
</script>
<template>
<div style="display:flex;flex-direction:column;gap:16px;width:100%;">
<VPagination v-model="page" :total="240" :page-size="10" size="sm" />
<VPagination v-model="page" :total="240" :page-size="10" size="md" />
<VPagination v-model="page" :total="240" :page-size="10" size="lg" />
</div>
</template>First Page
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(1)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'default',
modelValue: 1
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>Last Page
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(24)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'default',
modelValue: 24
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>Disabled
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(3)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'default',
modelValue: 3,
disabled: true,
showPageSize: true,
showResultCount: true
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>Loading
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const page = ref(3)
const pageSize = ref(10)
const storyArgs = {
total: 240,
pageSize: 10,
size: 'md',
variant: 'default',
modelValue: 3,
loading: true,
showPageSize: true,
showResultCount: true
}
</script>
<template>
<VPagination
v-model="page"
:total="storyArgs.total ?? 240"
:page-size="pageSize"
:size="storyArgs.size ?? 'md'"
:variant="storyArgs.variant ?? 'default'"
:disabled="Boolean(storyArgs.disabled)"
:loading="Boolean(storyArgs.loading)"
:show-page-size="Boolean(storyArgs.showPageSize)"
:show-result-count="Boolean(storyArgs.showResultCount)"
@update:page-size="pageSize = $event" />
</template>Interactive
Variação Interativo. Interativo: o estado é mantido na própria story (v-model).
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination, VButton } from 'vueui-nova-kit'
const page = ref(3)
const pageSize = ref(10)
const disabled = ref(false)
const loading = ref(false)
const stateLabel = () => {
if (loading.value) return "loading";
if (disabled.value) return "disabled";
return "default";
}
</script>
<template>
<div style="display:flex;flex-direction:column;gap:12px;width:100%;">
<p style="margin:0;color:var(--v-color-text-muted);font-size:14px;">
Página {{ page }} · {{ pageSize }} itens/página · estado: {{ stateLabel() }}
</p>
<VPagination
v-model="page"
:total="240"
:page-size="pageSize"
:disabled="disabled"
:loading="loading"
show-page-size
show-result-count
@update:page-size="pageSize = $event" />
<div style="display:flex;gap:8px;flex-wrap:wrap;">
<VButton variant="secondary" size="sm" @click="disabled = !disabled">
{{ disabled ? 'Habilitar' : 'Desabilitar' }}
</button>
<VButton variant="secondary" size="sm" @click="loading = !loading">
{{ loading ? 'Parar loading' : 'Simular loading' }}
</button>
</div>
</div>
</template>Sibling And Boundary Count
Variação Sibling e Boundary Count. Props: total=500, pageSize=10, modelValue=25, siblingCount=2, boundaryCount=2.
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const value = ref(25)
</script>
<template>
<VPagination
v-model="value"
:total="500"
:sibling-count="2"
:boundary-count="2" />
</template>Page Count
Variação Page Count. Props: pageCount=12, modelValue=6.
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VPagination } from 'vueui-nova-kit'
const value = ref(6)
</script>
<template>
<VPagination v-model="value" :total="240" :page-count="12" />
</template>Page Size Options
Variação Page tamanho Options. Props: total=240, showPageSize=true, showResultCount=true.
Ver código
<script setup lang="ts">
import { VPagination } from 'vueui-nova-kit'
const pageSizeOptions = [10, 25, 50, 100]
</script>
<template>
<VPagination
v-model="value"
:total="240"
show-page-size
:page-size-options="pageSizeOptions"
show-result-count />
</template>Custom Labels
Variação Personalizado Labels. Props: prevLabel="Anterior", nextLabel="Próxima", pageSizeLabel="Itens por página", showPageSize=true.
Ver código
<script setup lang="ts">
import { VPagination } from 'vueui-nova-kit'
</script>
<template>
<VPagination
v-model="value"
:total="240"
prev-label="Anterior"
next-label="Próxima"
page-size-label="Itens por página"
show-page-size />
</template>Acessibilidade
<nav aria-label="Pagination">como rootaria-current="page"na página ativaaria-labelem prev/next e em cada página- Ellipsis com
aria-hidden="true" - Botões desabilitados com atributo
disablednativo - Teclado: Tab entre controles, ArrowLeft/ArrowRight em prev/next, Enter na página focada
Estados
Default · Hover · Focus-visible · Pressed · Active (página selecionada) · Disabled (componente inteiro) · Loading (spinner sobre os controles).
Layout inline com page size: paginação à esquerda, "Items per page" + dropdown + "Showing X–Y of
Motion
| Trigger | Property | Duration | Easing |
|---|---|---|---|
| Hover | background | 160ms | ease-out |
| Pressed | transform | 80ms | ease-in |
| Active change | background/color | 300ms | ease-in-out |
| Focus | outline | 100ms | standard |
Respeitar prefers-reduced-motion.
Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.
Props
| Prop | Tipo | Default | Descrição |
|---|---|---|---|
modelValue | number | — | — |
total | number | 0 | — |
pageSize | number | 10 | — |
pageCount | number | — | — |
siblingCount | number | — | — |
boundaryCount | number | — | — |
disabled | boolean | false | — |
loading | boolean | false | — |
size | VPaginationSize | "md" | — |
variant | VPaginationVariant | "default" | — |
showPageSize | boolean | false | — |
showResultCount | boolean | false | — |
pageSizeOptions | number[] | — | — |
prevLabel | string | — | — |
nextLabel | string | — | — |
pageSizeLabel | string | — | — |
ariaLabel | string | — | — |
Events
| Evento | Payload | Descrição |
|---|---|---|
@update:modelValue | page: number | — |
@update:page | page: number | — |
@update:pageSize | size: number | — |
Slots
Sem slots.
Fonte: src/components/navigation/VPagination/VPagination.vue · tipos: src/components/navigation/VPagination/VPagination.types.ts