Navegação

VPagination

Componentev-model14 exemplos17 propsA2UI · Pagination

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.

Importação
<script setup lang="ts">
import { VPagination } from 'vueui-nova-kit'
</script>

Uso

Exemplo
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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
vue
<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 root
  • aria-current="page" na página ativa
  • aria-label em prev/next e em cada página
  • Ellipsis com aria-hidden="true"
  • Botões desabilitados com atributo disabled nativo
  • 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

TriggerPropertyDurationEasing
Hoverbackground160msease-out
Pressedtransform80msease-in
Active changebackground/color300msease-in-out
Focusoutline100msstandard

Respeitar prefers-reduced-motion.

Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.

Props

PropTipoDefaultDescrição
modelValuenumber——
totalnumber0—
pageSizenumber10—
pageCountnumber——
siblingCountnumber——
boundaryCountnumber——
disabledbooleanfalse—
loadingbooleanfalse—
sizeVPaginationSize"md"—
variantVPaginationVariant"default"—
showPageSizebooleanfalse—
showResultCountbooleanfalse—
pageSizeOptionsnumber[]——
prevLabelstring——
nextLabelstring——
pageSizeLabelstring——
ariaLabelstring——

Events

EventoPayloadDescrição
@update:modelValuepage: number—
@update:pagepage: number—
@update:pageSizesize: number—

Slots

Sem slots.

Fonte: src/components/navigation/VPagination/VPagination.vue · tipos: src/components/navigation/VPagination/VPagination.types.ts