|
1 | 1 | <script setup>
|
2 |
| -import PaginationExample from './pagination/examples/FwbPaginationExample.vue'; |
3 |
| -import PaginationNavigationExample from './pagination/examples/FwbPaginationExampleNavigation.vue'; |
4 |
| -import PaginationTableExample from './pagination/examples/FwbPaginationExampleTable.vue'; |
5 |
| -import PaginationWithIconsExample from './pagination/examples/FwbPaginationExampleWithIcons.vue'; |
6 |
| -import PaginationWithCustomTextExample from './pagination/examples/FwbPaginationExampleWithCustomText.vue'; |
7 |
| -import PaginationWithCustomSlice from './pagination/examples/FwbPaginationExampleWithCustomSlice.vue'; |
8 |
| -import PaginationSlotsExample from './pagination/examples/FwbPaginationExampleSlots.vue'; |
| 2 | +import FwbPaginationExample from './pagination/examples/FwbPaginationExample.vue'; |
| 3 | +import FwbPaginationExampleIcons from './pagination/examples/FwbPaginationExampleIcons.vue'; |
| 4 | +import FwbPaginationExampleNavigation from './pagination/examples/FwbPaginationExampleNavigation.vue'; |
| 5 | +import FwbPaginationExampleNavigationIcons from './pagination/examples/FwbPaginationExampleNavigationIcons.vue'; |
| 6 | +import FwbPaginationExampleSlots from './pagination/examples/FwbPaginationExampleSlots.vue'; |
| 7 | +import FwbPaginationExampleTable from './pagination/examples/FwbPaginationExampleTable.vue'; |
| 8 | +import FwbPaginationExampleCustomLength from './pagination/examples/FwbPaginationExampleCustomLength.vue'; |
| 9 | +import FwbPaginationExampleCustomLabels from './pagination/examples/FwbPaginationExampleCustomLabels.vue'; |
9 | 10 | </script>
|
| 11 | + |
10 | 12 | # Vue Pagination - Flowbite
|
11 |
| -#### Use the Tailwind CSS pagination element to indicate a series of content across various pages based on multiple styles and sizes |
| 13 | +#### Use the Tailwind CSS pagination element to indicate a series of content across various pages based on multiple styles and sizes. |
12 | 14 | 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.
|
13 | 15 |
|
14 | 16 | ## Default pagination
|
15 | 17 | 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.
|
16 | 18 |
|
17 |
| -<PaginationExample /> |
| 19 | +<fwb-pagination-example /> |
18 | 20 |
|
19 | 21 | ```vue
|
| 22 | +<template> |
| 23 | + <fwb-pagination |
| 24 | + v-model="currentPage" |
| 25 | + :total-items="100" |
| 26 | + /> |
| 27 | + <fwb-pagination |
| 28 | + v-model="currentPage" |
| 29 | + :total-items="100" |
| 30 | + large |
| 31 | + /> |
| 32 | +</template> |
| 33 | +
|
20 | 34 | <script setup>
|
21 | 35 | import { FwbPagination } from 'flowbite-vue'
|
22 | 36 | import { ref } from 'vue'
|
23 | 37 |
|
24 | 38 | const currentPage = ref(1)
|
25 | 39 | </script>
|
26 |
| -<template> |
27 |
| - <fwb-pagination v-model="currentPage" :total-items="100"></fwb-pagination> |
28 |
| - <fwb-pagination v-model="currentPage" :total-items="100" large></fwb-pagination> |
29 |
| -</template> |
30 | 40 | ```
|
31 | 41 |
|
32 | 42 | ## Pagination with icons
|
33 | 43 | The following pagination component example shows how you can use SVG icons instead of text to show the previous and next pages.
|
34 | 44 |
|
35 |
| -<PaginationWithIconsExample /> |
| 45 | +<fwb-pagination-example-icons /> |
36 | 46 |
|
37 | 47 | ```vue
|
| 48 | +<template> |
| 49 | + <fwb-pagination |
| 50 | + v-model="currentPage" |
| 51 | + :total-pages="100" |
| 52 | + hide-labels |
| 53 | + show-icons |
| 54 | + /> |
| 55 | + <fwb-pagination |
| 56 | + v-model="currentPage" |
| 57 | + :total-pages="100" |
| 58 | + hide-labels |
| 59 | + show-icons |
| 60 | + large |
| 61 | + /> |
| 62 | +</template> |
| 63 | +
|
38 | 64 | <script setup>
|
39 | 65 | import { FwbPagination } from 'flowbite-vue'
|
40 | 66 | import { ref } from 'vue'
|
41 | 67 |
|
42 | 68 | const currentPage = ref(1)
|
43 | 69 | </script>
|
44 |
| -<template> |
45 |
| - <fwb-pagination v-model="currentPage" :total-pages="100" show-icons></fwb-pagination> |
46 |
| -</template> |
47 | 70 | ```
|
48 | 71 |
|
| 72 | +## Custom length pagination |
| 73 | +You can use your own pages count in the row by passing props: `slice-length` |
| 74 | +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 = 9` pages. |
49 | 75 |
|
| 76 | +<fwb-pagination-example-custom-length /> |
| 77 | +```vue |
| 78 | +<template> |
| 79 | + <fwb-pagination |
| 80 | + v-model="currentPage" |
| 81 | + :slice-length="4" |
| 82 | + :total-pages="100" |
| 83 | + /> |
| 84 | +</template> |
50 | 85 |
|
| 86 | +<script setup> |
| 87 | +import { FwbPagination } from 'flowbite-vue' |
| 88 | +import { ref } from 'vue' |
51 | 89 |
|
| 90 | +const currentPage = ref(5) |
| 91 | +</script> |
| 92 | +``` |
52 | 93 |
|
| 94 | +## Previous and next |
53 | 95 |
|
54 |
| -## Default with custom length |
55 |
| -You can use your own pages count in the row by passing props: `slice-length` |
56 |
| -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. |
57 |
| - |
| 96 | +<fwb-pagination-example-navigation /> |
58 | 97 | ```vue
|
| 98 | +<template> |
| 99 | + <fwb-pagination |
| 100 | + v-model="currentPage" |
| 101 | + :layout="'navigation'" |
| 102 | + :total-pages="100" |
| 103 | + /> |
| 104 | + <fwb-pagination |
| 105 | + v-model="currentPage" |
| 106 | + :layout="'navigation'" |
| 107 | + :total-pages="100" |
| 108 | + large |
| 109 | + /> |
| 110 | +</template> |
| 111 | +
|
59 | 112 | <script setup>
|
60 | 113 | import { FwbPagination } from 'flowbite-vue'
|
61 | 114 | import { ref } from 'vue'
|
62 | 115 |
|
63 | 116 | const currentPage = ref(1)
|
64 | 117 | </script>
|
65 |
| -<template> |
66 |
| - <fwb-pagination v-model="currentPage" :total-pages="100" :slice-length="4"></fwb-pagination> |
67 |
| -</template> |
68 | 118 | ```
|
69 | 119 |
|
70 |
| -<PaginationWithCustomSlice /> |
71 |
| - |
72 |
| -## Previous and next |
| 120 | +## Previous and next with icons |
73 | 121 |
|
| 122 | +<fwb-pagination-example-navigation-icons /> |
74 | 123 | ```vue
|
| 124 | +<template> |
| 125 | + <fwb-pagination |
| 126 | + v-model="currentPage" |
| 127 | + :layout="'navigation'" |
| 128 | + :total-pages="100" |
| 129 | + show-icons |
| 130 | + /> |
| 131 | + <fwb-pagination |
| 132 | + v-model="currentPage" |
| 133 | + :layout="'navigation'" |
| 134 | + :total-pages="100" |
| 135 | + show-icons |
| 136 | + large |
| 137 | + /> |
| 138 | +</template> |
| 139 | +
|
75 | 140 | <script setup>
|
76 | 141 | import { FwbPagination } from 'flowbite-vue'
|
77 | 142 | import { ref } from 'vue'
|
78 | 143 |
|
79 | 144 | const currentPage = ref(1)
|
80 | 145 | </script>
|
81 |
| -<template> |
82 |
| - <div class="flex items-center justify-center text-center"> |
83 |
| - <fwb-pagination v-model="currentPage" :total-pages="10" :layout="'navigation'"></fwb-pagination> |
84 |
| - </div> |
85 |
| -</template> |
86 | 146 | ```
|
87 | 147 |
|
88 |
| -<PaginationNavigationExample /> |
89 |
| - |
90 |
| -## Pagination with table layout |
| 148 | +## Table data pagination |
| 149 | +You can use the following markup to show the number of data shown inside a table element and also the previous and next action buttons. |
91 | 150 | To use that layout you have to pass required props:
|
92 | 151 | - `per-page`: it's items count displayed on each page.
|
93 | 152 | - `total-items`: it's the total items count.
|
94 | 153 |
|
95 |
| -And there you don't need to use `total-pages` prop. |
| 154 | +_And here you don't need to use `total-pages` prop._ |
96 | 155 |
|
| 156 | +<fwb-pagination-example-table /> |
97 | 157 | ```vue
|
| 158 | +<template> |
| 159 | + <fwb-pagination |
| 160 | + v-model="currentPageA" |
| 161 | + :layout="'table'" |
| 162 | + :per-page="20" |
| 163 | + :total-items="100" |
| 164 | + /> |
| 165 | + <fwb-pagination |
| 166 | + v-model="currentPageB" |
| 167 | + :layout="'table'" |
| 168 | + :per-page="100" |
| 169 | + :total-items="550" |
| 170 | + large |
| 171 | + /> |
| 172 | +</template> |
| 173 | +
|
98 | 174 | <script setup>
|
99 | 175 | import { FwbPagination } from 'flowbite-vue'
|
100 | 176 | import { ref } from 'vue'
|
101 | 177 |
|
102 |
| -const currentPage = ref(1) |
| 178 | +const currentPageA = ref(1) |
| 179 | +const currentPageB = ref(1) |
103 | 180 | </script>
|
104 |
| -<template> |
105 |
| - <div class="flex items-center justify-center text-center"> |
106 |
| - <fwb-pagination v-model="currentPage" :layout="'table'" :per-page="20" :total-items="998" class="mb-2" /> |
107 |
| - <fwb-pagination v-model="currentPage" :layout="'table'" :per-page="20" :total-items="998" large /> |
108 |
| - </div> |
109 |
| -</template> |
110 | 181 | ```
|
111 | 182 |
|
112 |
| -<PaginationTableExample /> |
113 | 183 |
|
114 | 184 | ## Pagination with custom labels
|
115 | 185 |
|
| 186 | +<fwb-pagination-example-custom-labels /> |
116 | 187 | ```vue
|
| 188 | +<template> |
| 189 | + <fwb-pagination |
| 190 | + v-model="currentPage" |
| 191 | + :total-pages="100" |
| 192 | + previous-label="<<<" |
| 193 | + next-label=">>>" |
| 194 | + /> |
| 195 | +</template> |
| 196 | +
|
117 | 197 | <script setup>
|
118 | 198 | import { FwbPagination } from 'flowbite-vue'
|
119 | 199 | import { ref } from 'vue'
|
120 | 200 |
|
121 | 201 | const currentPage = ref(1)
|
122 | 202 | </script>
|
123 |
| -<template> |
124 |
| - <fwb-pagination v-model="currentPage" :total-pages="100" previous-label="<<<" next-label=">>>"></fwb-pagination> |
125 |
| -</template> |
126 | 203 | ```
|
127 |
| -<PaginationWithCustomTextExample /> |
128 | 204 |
|
129 | 205 |
|
130 | 206 | ## Slots example
|
131 | 207 |
|
132 |
| -<PaginationSlotsExample /> |
| 208 | +<fwb-pagination-example-slots /> |
133 | 209 |
|
134 | 210 | ```vue
|
135 |
| -<script setup> |
136 |
| -import { FwbPagination } from 'flowbite-vue' |
137 |
| -import { ref } from 'vue' |
138 |
| -
|
139 |
| -const currentPage = ref(1) |
140 |
| -</script> |
141 | 211 | <template>
|
142 |
| - <fwb-pagination v-model="currentPage" :total-items="100" :show-labels="false"> |
| 212 | + <fwb-pagination |
| 213 | + v-model="currentPage" |
| 214 | + :total-items="100" |
| 215 | + hide-labels |
| 216 | + > |
143 | 217 | <template #prev-icon>⬅️</template>
|
144 | 218 | <template #next-icon>➡️</template>
|
145 |
| - <template v-slot:page-button="{ page, setPage }"> |
146 |
| - <button |
147 |
| - @click="setPage(page)" |
148 |
| - 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" |
149 |
| - > |
| 219 | + <template #page-button="{ page, setPage }"> |
| 220 | + <button @click="setPage(page)" class="ml-0 flex h-8 items-center justify-center border border-purple-300 bg-purple-200 px-3 leading-tight text-gray-500 first:rounded-l-lg last:rounded-r-lg hover:bg-purple-300 hover:text-gray-700 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"> |
150 | 221 | {{ page }}
|
151 | 222 | </button>
|
152 | 223 | </template>
|
153 | 224 | </fwb-pagination>
|
154 | 225 | Current page: {{ currentPage }}
|
155 | 226 | </template>
|
| 227 | +
|
| 228 | +<script setup> |
| 229 | +import { FwbPagination } from 'flowbite-vue' |
| 230 | +import { ref } from 'vue' |
| 231 | +
|
| 232 | +const currentPage = ref(1) |
| 233 | +</script> |
156 | 234 | ```
|
157 | 235 |
|
158 | 236 | ## API
|
159 | 237 |
|
160 | 238 | ### Props
|
161 |
| -| Name | Values | Default | |
162 |
| -|---------------------------|-------------------------------------|--------------| |
163 |
| -| modelValue | `number` | `1` | |
164 |
| -| totalPages | `number` | `10` | |
165 |
| -| perPage | `number` | `10` | |
166 |
| -| totalItems | `number` | `10` | |
167 |
| -| layout | `pagination`, `table`, `navigation` | `pagination` | |
168 |
| -| showIcons | `boolean` | `false` | |
169 |
| -| sliceLength | `number` | `2` | |
170 |
| -| previousLabel | `string` | `Previous` | |
171 |
| -| nextLabel | `string` | `Next` | |
172 |
| -| enableFirstAndLastButtons | `boolean` | `false` | |
173 |
| -| showLabels | `boolean` | `true` | |
174 |
| -| large | `boolean` | `false` | |
| 239 | +| Name | Values | Default | |
| 240 | +| --------------- | ----------------------------------- | ------------ | |
| 241 | +| modelValue | `number` | `1` | |
| 242 | +| totalPages | `number` | `10` | |
| 243 | +| perPage | `number` | `10` | |
| 244 | +| totalItems | `number` | `10` | |
| 245 | +| layout | `pagination`, `table`, `navigation` | `pagination` | |
| 246 | +| showIcons | `boolean` | `false` | |
| 247 | +| sliceLength | `number` | `2` | |
| 248 | +| previousLabel | `string` | `Previous` | |
| 249 | +| nextLabel | `string` | `Next` | |
| 250 | +| enableFirstLast | `boolean` | `false` | |
| 251 | +| hideLabels | `boolean` | `false` | |
| 252 | +| large | `boolean` | `false` | |
175 | 253 |
|
176 | 254 | ### Events
|
177 | 255 | | Name | Description |
|
178 |
| -|----------------------|----------------------| |
| 256 | +| -------------------- | -------------------- | |
179 | 257 | | `update:model-value` | Current page changed |
|
180 | 258 | | `page-changed` | Current page changed |
|
181 | 259 |
|
182 | 260 | ### Slots
|
183 |
| -| Name | Description | |
184 |
| -|--------------|-------------------------| |
185 |
| -| start | content before buttons | |
186 |
| -| end | content after buttons | |
187 |
| -| first-button | first button content | |
188 |
| -| last-button | last button content | |
189 |
| -| prev-button | previous button content | |
190 |
| -| next-button | next button content | |
191 |
| -| prev-icon | previous icon slot | |
192 |
| -| next-icon | next icon slot | |
193 |
| -| page-button | page button slot | |
| 261 | +| Name | Description | |
| 262 | +| -------------- | ----------------------- | |
| 263 | +| `start` | content before buttons | |
| 264 | +| `first-icon` | first icon content | |
| 265 | +| `first-button` | first button content | |
| 266 | +| `prev-icon` | previous icon content | |
| 267 | +| `prev-button` | previous button content | |
| 268 | +| `page-button` | page button content | |
| 269 | +| `next-button` | next button content | |
| 270 | +| `next-icon` | next icon content | |
| 271 | +| `last-button` | last button content | |
| 272 | +| `last-icon` | last icon content | |
| 273 | +| `end` | content after buttons | |
0 commit comments