Files
flowbite-vue/docs/components/pagination.md
Ilya Artamonov d316cf3a12 Components renaming (#225)
* refactor: eslint config adjusted for better diff's

* refactor: stricter linting
 + dependencies updated

* refactoring: paragraph component
 - component
 - docs

* refactoring: heading component
 - component
 - docs

* Update docs/components/heading.md

Co-authored-by: Ilya Artamonov <ilya.sosidka@gmail.com>

* refactoring: link component
 - component
 - docs

* refactoring: image component
 - component
 - docs

* refactoring: alert component
 - component
 - docs

* refactoring: avatar component
 - component
 - docs

* refactoring: removed unnecessary code
    - component names come from the file name

* refactoring: breadcrumb component
 - component
 - docs

* refactoring: accordion component
 - component
 - docs

* refactoring: buttom component
 - component
 - docs

* refactoring: badge component
 - component
 - docs

* refactoring: card component
 - component
 - docs

* refactoring: order of components in docs updated

* refactoring: unnecessary semicolons removed

* refactoring: button group component
 - component
 - docs

* refactoring: carousel component
 - component
 - docs

* refactoring: dropdown component
 - component
 - docs

* refactoring: footer component
 - component
 - docs

* refactoring:list-group component
 - component
 - docs

* refactoring: modal component
 - component
 - docs

* refactoring: navbar component
 - component
 - docs

* refactoring: pagination component
 - component
 - docs

* refactoring: progress component
 - component
 - docs

* refactoring: rating component
 - component
 - docs

* refactoring: spinner component
 - component
 - docs

* refactoring: table component
 - component
 - docs

* refactoring: tabs component
 - component
 - docs

* feat: Updated pagination examples

* lint: Lister fixes

* feat: Sidebar component and some fixes

* feat: Input component

* feat: Some fixes

* feat: Some fixes

* chore: update deps

* refactor: removed old Modal component

* refactor: radio component and some fixes

* fix: fixed path error

* refactor: Range component

* refactoring: timeline component
 - component
 - docs

* refactor: Select component

* refactoring: toast component
 - component
 - docs

* refactoring: tooltip component
 - component
 - docs

* refactoring: sidebar component
 - component
 - docs

* refactoring: input component
 - component
 - docs

* refactoring: fileInput component
 - component
 - docs

* refactoring: select component
 - component
 - docs

* refactoring: textarea component
 - component
 - docs

* refactoring: checkbox component
 - component
 - docs

* refactoring: radio component
 - component
 - docs

* refactoring: toggle component
 - component
 - docs

* refactoring: range component
 - component
 - docs

* local configs linted

* documentation quick start updated

* flowbite-themable refactored to fit new linters and style guide

* random linter fixes

* refactoring: toast-provider component
 - component
 - docs

* final linter fixes

* lint: Linter fixes

* fix: Fixed types

* fix: Fixed card component

* docs: Updated card examples

* fix: Fixed tabs

* refactor: Heading component refactoring

* Fwb rename - few fixes after component review (#237)

* fix: button documentation

* fix: model type in range examples

* chore: Toast marked as WIP

---------

Co-authored-by: Sqrcz <naorniakowski@slashlab.pl>
Co-authored-by: Sqrcz <naorniakowski@gmail.com>
2023-10-23 18:23:14 +03:00

6.7 KiB

<script setup> import PaginationExample from './pagination/examples/FwbPaginationExample.vue'; import PaginationNavigationExample from './pagination/examples/FwbPaginationExampleNavigation.vue'; import PaginationTableExample from './pagination/examples/FwbPaginationExampleTable.vue'; import PaginationWithIconsExample from './pagination/examples/FwbPaginationExampleWithIcons.vue'; import PaginationWithCustomTextExample from './pagination/examples/FwbPaginationExampleWithCustomText.vue'; import PaginationWithCustomSlice from './pagination/examples/FwbPaginationExampleWithCustomSlice.vue'; import PaginationSlotsExample from './pagination/examples/FwbPaginationExampleSlots.vue'; </script>

Vue Pagination - Flowbite

Use the Tailwind CSS pagination element to indicate a series of content across various pages based on multiple styles and sizes

The pagination component can be used to navigate across a series of content and data sets for various pages such as blog posts, products, and more. You can use multiple variants of this component with or without icons and even for paginating table data entries.

Default pagination

Use the following list of pagination items based on two sizes powered by Tailwind CSS utility classes to indicate a series of content for your website.

<script setup>
import { FwbPagination } from 'flowbite-vue'
import { ref } from 'vue'

const currentPage = ref(1)
</script>
<template>
  <fwb-pagination v-model="currentPage" :total-items="100"></fwb-pagination>
  <fwb-pagination v-model="currentPage" :total-items="100" large></fwb-pagination>
</template>

Pagination with icons

The following pagination component example shows how you can use SVG icons instead of text to show the previous and next pages.

<script setup>
import { FwbPagination } from 'flowbite-vue'
import { ref } from 'vue'

const currentPage = ref(1)
</script>
<template>
  <fwb-pagination v-model="currentPage" :total-pages="100" show-icons></fwb-pagination>
</template>

Default with custom length

You can use your own pages count in the row by passing props: slice-length This prop means left side and right side pages row slicing. In the example it has value 4. So row length will be 4 + 1 + 4 pages - 9 pages.

<script setup>
import { FwbPagination } from 'flowbite-vue'
import { ref } from 'vue'

const currentPage = ref(1)
</script>
<template>
  <fwb-pagination v-model="currentPage" :total-pages="100" :slice-length="4"></fwb-pagination>
</template>

Previous and next

<script setup>
import { FwbPagination } from 'flowbite-vue'
import { ref } from 'vue'

const currentPage = ref(1)
</script>
<template>
  <div class="flex items-center justify-center text-center">
    <fwb-pagination v-model="currentPage" :total-pages="10" :layout="'navigation'"></fwb-pagination>
  </div>
</template>

Pagination with table layout

To use that layout you have to pass required props:

  • per-page: it's items count displayed on each page.
  • total-items: it's the total items count.

And there you don't need to use total-pages prop.

<script setup>
import { FwbPagination } from 'flowbite-vue'
import { ref } from 'vue'

const currentPage = ref(1)
</script>
<template>
  <div class="flex items-center justify-center text-center">
    <fwb-pagination v-model="currentPage" :layout="'table'" :per-page="20" :total-items="998" class="mb-2" />
    <fwb-pagination v-model="currentPage" :layout="'table'" :per-page="20" :total-items="998" large />
  </div>
</template>

Pagination with custom labels

<script setup>
import { FwbPagination } from 'flowbite-vue'
import { ref } from 'vue'

const currentPage = ref(1)
</script>
<template>
  <fwb-pagination v-model="currentPage" :total-pages="100" previous-label="<<<" next-label=">>>"></fwb-pagination>
</template>

Slots example

<script setup>
import { FwbPagination } from 'flowbite-vue'
import { ref } from 'vue'

const currentPage = ref(1)
</script>
<template>
  <fwb-pagination v-model="currentPage" :total-items="100" :show-labels="false">
    <template #prev-icon>⬅️</template>
    <template #next-icon>➡️</template>
    <template v-slot:page-button="{ page, setPage }">
      <button
          @click="setPage(page)"
          class="flex items-center justify-center first:rounded-l-lg last:rounded-r-lg px-3 h-8 ml-0 leading-tight text-gray-500 bg-purple-200 border border-purple-300 hover:bg-purple-300 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
      >
        {{ page }}
      </button>
    </template>
  </fwb-pagination>
  Current page: {{ currentPage }}
</template>

API

Props

Name Values Default
modelValue number 1
totalPages number 10
perPage number 10
totalItems number 10
layout pagination, table, navigation pagination
showIcons boolean false
sliceLength number 2
previousLabel string Previous
nextLabel string Next
enableFirstAndLastButtons boolean false
showLabels boolean true
large boolean false

Events

Name Description
update:model-value Current page changed
page-changed Current page changed

Slots

Name Description
start content before buttons
end content after buttons
first-button first button content
last-button last button content
prev-button previous button content
next-button next button content
prev-icon previous icon slot
next-icon next icon slot
page-button page button slot