flowbite-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +324 -0
  3. package/build/index.js +975 -0
  4. package/build/server-runner.js +228 -0
  5. package/data/components/accordion.md +860 -0
  6. package/data/components/alerts.md +739 -0
  7. package/data/components/avatar.md +178 -0
  8. package/data/components/badge.md +420 -0
  9. package/data/components/banner.md +145 -0
  10. package/data/components/bottom-navigation.md +513 -0
  11. package/data/components/breadcrumb.md +273 -0
  12. package/data/components/button-group.md +410 -0
  13. package/data/components/buttons.md +405 -0
  14. package/data/components/card.md +711 -0
  15. package/data/components/carousel.md +858 -0
  16. package/data/components/chat-bubble.md +1063 -0
  17. package/data/components/clipboard.md +1029 -0
  18. package/data/components/datepicker.md +673 -0
  19. package/data/components/device-mockups.md +152 -0
  20. package/data/components/drawer.md +1353 -0
  21. package/data/components/dropdowns.md +1925 -0
  22. package/data/components/footer.md +299 -0
  23. package/data/components/forms.md +371 -0
  24. package/data/components/gallery.md +322 -0
  25. package/data/components/indicators.md +262 -0
  26. package/data/components/jumbotron.md +213 -0
  27. package/data/components/kbd.md +217 -0
  28. package/data/components/list-group.md +365 -0
  29. package/data/components/mega-menu.md +558 -0
  30. package/data/components/modal.md +1309 -0
  31. package/data/components/navbar.md +1053 -0
  32. package/data/components/pagination.md +472 -0
  33. package/data/components/popover.md +826 -0
  34. package/data/components/progress.md +95 -0
  35. package/data/components/qr-code.md +280 -0
  36. package/data/components/rating.md +323 -0
  37. package/data/components/sidebar.md +1067 -0
  38. package/data/components/skeleton.md +221 -0
  39. package/data/components/speed-dial.md +1270 -0
  40. package/data/components/spinner.md +222 -0
  41. package/data/components/stepper.md +271 -0
  42. package/data/components/tables.md +3127 -0
  43. package/data/components/tabs.md +808 -0
  44. package/data/components/timeline.md +304 -0
  45. package/data/components/toast.md +341 -0
  46. package/data/components/tooltips.md +524 -0
  47. package/data/components/typography.md +269 -0
  48. package/data/components/video.md +95 -0
  49. package/data/forms/checkbox.md +375 -0
  50. package/data/forms/file-input.md +98 -0
  51. package/data/forms/floating-label.md +185 -0
  52. package/data/forms/input-field.md +222 -0
  53. package/data/forms/number-input.md +1099 -0
  54. package/data/forms/phone-input.md +577 -0
  55. package/data/forms/radio.md +315 -0
  56. package/data/forms/range.md +83 -0
  57. package/data/forms/search-input.md +280 -0
  58. package/data/forms/select.md +259 -0
  59. package/data/forms/textarea.md +155 -0
  60. package/data/forms/timepicker.md +732 -0
  61. package/data/forms/toggle.md +176 -0
  62. package/data/plugins/charts.md +2683 -0
  63. package/data/plugins/datatables.md +1922 -0
  64. package/data/plugins/datepicker.md +5 -0
  65. package/data/plugins/wysiwyg.md +2377 -0
  66. package/data/quickstart.md +169 -0
  67. package/data/theme.md +231 -0
  68. package/data/toc.md +79 -0
  69. package/data/typography/blockquote.md +182 -0
  70. package/data/typography/headings.md +174 -0
  71. package/data/typography/hr.md +74 -0
  72. package/data/typography/images.md +168 -0
  73. package/data/typography/links.md +118 -0
  74. package/data/typography/lists.md +387 -0
  75. package/data/typography/paragraphs.md +186 -0
  76. package/data/typography/text.md +249 -0
  77. package/package.json +71 -0
@@ -0,0 +1,858 @@
1
+ ---
2
+ layout: docs
3
+ title: Tailwind CSS Carousel - Flowbite
4
+ description: Use the carousel component to slide through multiple elements and images using custom controls, indicators, intervals, and options
5
+ group: components
6
+ toc: true
7
+ requires_js: true
8
+
9
+ previous: Card
10
+ previousLink: components/card/
11
+ next: Chat bubble
12
+ nextLink: components/chat-bubble/
13
+ ---
14
+
15
+ The carousel component can be used to cycle through a set of elements using custom options, controls, and indicators based on the JavaScript object from Flowbite.
16
+
17
+ ## Default slider
18
+
19
+ The carousel component can be initialized by using the `data-carousel={static|slide}` data attribute and by applying a unique `id` attribute to the parent element.
20
+
21
+ - `data-carousel="static"` to prevent the carousel sliding by default
22
+ - `data-carousel="slide"` to infinitely cycle through the items
23
+
24
+ You can add as many carousel items as you want, but make sure that you add the `data-carousel-item` data attribute to each of them and set a single item to active by applying the `active` value to the data attribute.
25
+
26
+ Use the `duration-*` and the animation classes from Tailwind CSS to apply custom effects to the carousel items and don't forget to set the `hidden` class by default to prevent flickering.
27
+
28
+ {{< example github="components/carousel.md" show_dark=true >}}
29
+
30
+ <div id="default-carousel" class="relative w-full" data-carousel="slide">
31
+ <!-- Carousel wrapper -->
32
+ <div class="relative h-56 overflow-hidden rounded-base md:h-96">
33
+ <!-- Item 1 -->
34
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
35
+ <img src="/docs/images/carousel/carousel-1.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
36
+ </div>
37
+ <!-- Item 2 -->
38
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
39
+ <img src="/docs/images/carousel/carousel-2.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
40
+ </div>
41
+ <!-- Item 3 -->
42
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
43
+ <img src="/docs/images/carousel/carousel-3.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
44
+ </div>
45
+ <!-- Item 4 -->
46
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
47
+ <img src="/docs/images/carousel/carousel-4.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
48
+ </div>
49
+ <!-- Item 5 -->
50
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
51
+ <img src="/docs/images/carousel/carousel-5.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
52
+ </div>
53
+ </div>
54
+ <!-- Slider indicators -->
55
+ <div class="absolute z-30 flex -translate-x-1/2 bottom-5 left-1/2 space-x-3 rtl:space-x-reverse">
56
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="true" aria-label="Slide 1" data-carousel-slide-to="0"></button>
57
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 2" data-carousel-slide-to="1"></button>
58
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 3" data-carousel-slide-to="2"></button>
59
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 4" data-carousel-slide-to="3"></button>
60
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 5" data-carousel-slide-to="4"></button>
61
+ </div>
62
+ <!-- Slider controls -->
63
+ <button type="button" class="absolute top-0 start-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-prev>
64
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
65
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 19-7-7 7-7"/></svg>
66
+ <span class="sr-only">Previous</span>
67
+ </span>
68
+ </button>
69
+ <button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-next>
70
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
71
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m9 5 7 7-7 7"/></svg>
72
+ <span class="sr-only">Next</span>
73
+ </span>
74
+ </button>
75
+ </div>
76
+ {{< /example >}}
77
+
78
+ ## Controls
79
+
80
+ Use the `data-carousel-prev` and `data-carousel-next` data attribute to listen to click events which will trigger the slide event from the carousel component to each direction.
81
+
82
+ You can customize the control elements with the classes from Tailwind CSS anyhow you want.
83
+
84
+ {{< example github="components/carousel.md" show_dark=true >}}
85
+
86
+ <div id="controls-carousel" class="relative w-full" data-carousel="static">
87
+ <!-- Carousel wrapper -->
88
+ <div class="relative h-56 overflow-hidden rounded-base md:h-96">
89
+ <!-- Item 1 -->
90
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
91
+ <img src="/docs/images/carousel/carousel-1.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
92
+ </div>
93
+ <!-- Item 2 -->
94
+ <div class="hidden duration-700 ease-in-out" data-carousel-item="active">
95
+ <img src="/docs/images/carousel/carousel-2.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
96
+ </div>
97
+ <!-- Item 3 -->
98
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
99
+ <img src="/docs/images/carousel/carousel-3.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
100
+ </div>
101
+ <!-- Item 4 -->
102
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
103
+ <img src="/docs/images/carousel/carousel-4.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
104
+ </div>
105
+ <!-- Item 5 -->
106
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
107
+ <img src="/docs/images/carousel/carousel-5.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
108
+ </div>
109
+ </div>
110
+ <!-- Slider controls -->
111
+ <button type="button" class="absolute top-0 start-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-prev>
112
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
113
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 19-7-7 7-7"/></svg>
114
+ <span class="sr-only">Previous</span>
115
+ </span>
116
+ </button>
117
+ <button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-next>
118
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
119
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m9 5 7 7-7 7"/></svg>
120
+ <span class="sr-only">Next</span>
121
+ </span>
122
+ </button>
123
+ </div>
124
+ {{< /example >}}
125
+
126
+ ## Indicators
127
+
128
+ Show the carousel indicators by adding the `data-carousel-slide-to={position}` to any number or style of indicator elements where the value equals the position of the slider element.
129
+
130
+ {{< example github="components/carousel.md" show_dark=true >}}
131
+
132
+ <div id="indicators-carousel" class="relative w-full" data-carousel="static">
133
+ <!-- Carousel wrapper -->
134
+ <div class="relative h-56 overflow-hidden rounded-base md:h-96">
135
+ <!-- Item 1 -->
136
+ <div class="hidden duration-700 ease-in-out" data-carousel-item="active">
137
+ <img src="/docs/images/carousel/carousel-1.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
138
+ </div>
139
+ <!-- Item 2 -->
140
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
141
+ <img src="/docs/images/carousel/carousel-2.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
142
+ </div>
143
+ <!-- Item 3 -->
144
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
145
+ <img src="/docs/images/carousel/carousel-3.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
146
+ </div>
147
+ <!-- Item 4 -->
148
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
149
+ <img src="/docs/images/carousel/carousel-4.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
150
+ </div>
151
+ <!-- Item 5 -->
152
+ <div class="hidden duration-700 ease-in-out" data-carousel-item>
153
+ <img src="/docs/images/carousel/carousel-5.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
154
+ </div>
155
+ </div>
156
+ <!-- Slider indicators -->
157
+ <div class="absolute z-30 flex -translate-x-1/2 space-x-3 rtl:space-x-reverse bottom-5 left-1/2">
158
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="true" aria-label="Slide 1" data-carousel-slide-to="0"></button>
159
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 2" data-carousel-slide-to="1"></button>
160
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 3" data-carousel-slide-to="2"></button>
161
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 4" data-carousel-slide-to="3"></button>
162
+ <button type="button" class="w-3 h-3 rounded-base" aria-current="false" aria-label="Slide 5" data-carousel-slide-to="4"></button>
163
+ </div>
164
+ <!-- Slider controls -->
165
+ <button type="button" class="absolute top-0 start-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-prev>
166
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
167
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 19-7-7 7-7"/></svg>
168
+ <span class="sr-only">Previous</span>
169
+ </span>
170
+ </button>
171
+ <button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-next>
172
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
173
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m9 5 7 7-7 7"/></svg>
174
+ <span class="sr-only">Next</span>
175
+ </span>
176
+ </button>
177
+ </div>
178
+ {{< /example >}}
179
+
180
+ ## Animation
181
+
182
+ You can easily customize the duration and animation style of the carousel component by using the `duration-*` and `ease-*` utility classes from Tailwind CSS.
183
+
184
+ {{< example github="components/carousel.md" show_dark=true >}}
185
+
186
+ <div id="animation-carousel" class="relative w-full" data-carousel="static">
187
+ <!-- Carousel wrapper -->
188
+ <div class="relative h-56 overflow-hidden rounded-base md:h-96">
189
+ <!-- Item 1 -->
190
+ <div class="hidden duration-200 ease-linear" data-carousel-item>
191
+ <img src="/docs/images/carousel/carousel-1.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
192
+ </div>
193
+ <!-- Item 2 -->
194
+ <div class="hidden duration-200 ease-linear" data-carousel-item>
195
+ <img src="/docs/images/carousel/carousel-2.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
196
+ </div>
197
+ <!-- Item 3 -->
198
+ <div class="hidden duration-200 ease-linear" data-carousel-item="active">
199
+ <img src="/docs/images/carousel/carousel-3.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
200
+ </div>
201
+ <!-- Item 4 -->
202
+ <div class="hidden duration-200 ease-linear" data-carousel-item>
203
+ <img src="/docs/images/carousel/carousel-4.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
204
+ </div>
205
+ <!-- Item 5 -->
206
+ <div class="hidden duration-200 ease-linear" data-carousel-item>
207
+ <img src="/docs/images/carousel/carousel-5.svg" class="absolute block w-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2" alt="...">
208
+ </div>
209
+ </div>
210
+ <!-- Slider controls -->
211
+ <button type="button" class="absolute top-0 start-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-prev>
212
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
213
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 19-7-7 7-7"/></svg>
214
+ <span class="sr-only">Previous</span>
215
+ </span>
216
+ </button>
217
+ <button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none" data-carousel-next>
218
+ <span class="inline-flex items-center justify-center w-10 h-10 rounded-base bg-white/30 dark:bg-gray-800/30 group-hover:bg-white/50 dark:group-hover:bg-gray-800/60 group-focus:ring-4 group-focus:ring-white dark:group-focus:ring-gray-800/70 group-focus:outline-none">
219
+ <svg class="w-5 h-5 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m9 5 7 7-7 7"/></svg>
220
+ <span class="sr-only">Next</span>
221
+ </span>
222
+ </button>
223
+ </div>
224
+ {{< /example >}}
225
+
226
+ ## JavaScript behaviour
227
+
228
+ Use the **Carousel** class from Flowbite to create an object that you can use to apply custom styles, change the active slide item, set callback functions directly from JavaScript.
229
+
230
+ ### Object parameters
231
+
232
+ Pass the object parameters for the Carousel object to set the carousel items and options.
233
+
234
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
235
+ <table class="w-full text-sm text-left text-body">
236
+ <thead class="text-heading bg-neutral-secondary-soft">
237
+ <tr class="text-xs font-medium uppercase">
238
+ <th scope="col" class="px-6 py-3">
239
+ Parameter
240
+ </th>
241
+ <th scope="col" class="px-6 py-3">
242
+ Type
243
+ </th>
244
+ <th scope="col" class="px-6 py-3">
245
+ Required
246
+ </th>
247
+ <th scope="col" class="px-6 py-3">
248
+ Description
249
+ </th>
250
+ </tr>
251
+ </thead>
252
+ <tbody>
253
+ <tr class="border-b bg-neutral-primary border-default">
254
+ <td class="px-6 py-4 font-medium">
255
+ <code class="text-fg-brand">carouselElement</code>
256
+ </td>
257
+ <td class="px-6 py-4">
258
+ Element
259
+ </td>
260
+ <td class="px-6 py-4">
261
+ Required
262
+ </td>
263
+ <td class="px-6 py-4">
264
+ Parent HTML element of the carousel component.
265
+ </td>
266
+ </tr>
267
+ <tr class="border-b bg-neutral-primary border-default">
268
+ <td class="px-6 py-4 font-medium">
269
+ <code class="text-fg-brand">items</code>
270
+ </td>
271
+ <td class="px-6 py-4">
272
+ Array
273
+ </td>
274
+ <td class="px-6 py-4">
275
+ Required
276
+ </td>
277
+ <td class="px-6 py-4">
278
+ Pass an array of carousel item objects including the position and the element.
279
+ </td>
280
+ </tr>
281
+ <tr class="border-b bg-neutral-primary border-default">
282
+ <td class="px-6 py-4 font-medium">
283
+ <code class="text-fg-brand">options</code>
284
+ </td>
285
+ <td class="px-6 py-4">
286
+ Object
287
+ </td>
288
+ <td class="px-6 py-4">
289
+ Optional
290
+ </td>
291
+ <td class="px-6 py-4">
292
+ Pass an object of options to set the interval, indicators, and callback functions.
293
+ </td>
294
+ </tr>
295
+ <tr class="bg-neutral-primary">
296
+ <td class="px-6 py-4 font-medium">
297
+ <code class="text-fg-brand">instanceOptions</code>
298
+ </td>
299
+ <td class="px-6 py-4">
300
+ Object
301
+ </td>
302
+ <td class="px-6 py-4">
303
+ Optional
304
+ </td>
305
+ <td class="px-6 py-4">
306
+ Object of options that allows you to set a custom ID for the instance that is being added to the <a href="https://flowbite.com/docs/getting-started/javascript/#instance-options" class="underline hover:no-underline">Instance Manager</a> and whether to override or not an existing instance.
307
+ </td>
308
+ </tr>
309
+ </tbody>
310
+ </table>
311
+ </div>
312
+
313
+ ### Options
314
+
315
+ Use these options for the Carousel object to set the default position, interval, indicators, custom styles, and callback functions.
316
+
317
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
318
+ <table class="w-full text-sm text-left text-body">
319
+ <thead class="bg-neutral-secondary-soft">
320
+ <tr class="text-xs font-medium uppercase">
321
+ <th scope="col" class="px-6 py-3">
322
+ Option
323
+ </th>
324
+ <th scope="col" class="px-6 py-3">
325
+ Type
326
+ </th>
327
+ <th scope="col" class="px-6 py-3">
328
+ Description
329
+ </th>
330
+ </tr>
331
+ </thead>
332
+ <tbody>
333
+ <tr class="border-b bg-neutral-primary border-default">
334
+ <td class="px-6 py-4 font-medium">
335
+ <code class="text-fg-brand">defaultPosition</code>
336
+ </td>
337
+ <td class="px-6 py-4 font-medium">
338
+ Integer
339
+ </td>
340
+ <td class="px-6 py-4">
341
+ Set the default active slider item based on its position (starts from [0-x]).
342
+ </td>
343
+ </tr>
344
+ <tr class="border-b bg-neutral-primary border-default">
345
+ <td class="px-6 py-4 font-medium">
346
+ <code class="text-fg-brand">interval</code>
347
+ </td>
348
+ <td class="px-6 py-4 font-medium">
349
+ Integer
350
+ </td>
351
+ <td class="px-6 py-4">
352
+ Set the interval duration in milliseconds when the carousel is cycling.
353
+ </td>
354
+ </tr>
355
+ <tr class="border-b bg-neutral-primary border-default">
356
+ <td class="px-6 py-4 font-medium">
357
+ <code class="text-fg-brand">indicators</code>
358
+ </td>
359
+ <td class="px-6 py-4 font-medium">
360
+ Array
361
+ </td>
362
+ <td class="px-6 py-4">
363
+ An optional object of indicator elements and custom classes.
364
+ </td>
365
+ </tr>
366
+ <tr class="border-b bg-neutral-primary border-default">
367
+ <td class="px-6 py-4 font-medium">
368
+ <code class="text-fg-brand">onNext</code>
369
+ </td>
370
+ <td class="px-6 py-4 font-medium">
371
+ Function
372
+ </td>
373
+ <td class="px-6 py-4">
374
+ Set a callback function when the next carousel item has been shown.
375
+ </td>
376
+ </tr>
377
+ <tr class="border-b bg-neutral-primary border-default">
378
+ <td class="px-6 py-4 font-medium">
379
+ <code class="text-fg-brand">onPrev</code>
380
+ </td>
381
+ <td class="px-6 py-4 font-medium">
382
+ Function
383
+ </td>
384
+ <td class="px-6 py-4">
385
+ Set a callback function when the previous carousel item has been shown.
386
+ </td>
387
+ </tr>
388
+ <tr class="bg-neutral-primary">
389
+ <td class="px-6 py-4 font-medium">
390
+ <code class="text-fg-brand">onChange</code>
391
+ </td>
392
+ <td class="px-6 py-4 font-medium">
393
+ Function
394
+ </td>
395
+ <td class="px-6 py-4">
396
+ Set a callback function when the position of the carousel item has been changed.
397
+ </td>
398
+ </tr>
399
+ </tbody>
400
+ </table>
401
+ </div>
402
+
403
+ ### Methods
404
+
405
+ Use the following methods on the Carousel object to programmatically manipulate the behaviour.
406
+
407
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
408
+ <table class="w-full text-sm text-left text-body">
409
+ <thead class="bg-neutral-secondary-soft">
410
+ <tr class="text-xs font-medium uppercase">
411
+ <th scope="col" class="px-6 py-3">
412
+ Method
413
+ </th>
414
+ <th scope="col" class="px-6 py-3">
415
+ Description
416
+ </th>
417
+ </tr>
418
+ </thead>
419
+ <tbody>
420
+ <tr class="border-b bg-neutral-primary border-default">
421
+ <td class="px-6 py-4 font-medium">
422
+ <code class="text-fg-brand">next()</code>
423
+ </td>
424
+ <td class="px-6 py-4">
425
+ Use this method to go to the next slide of the carousel component.
426
+ </td>
427
+ </tr>
428
+ <tr class="border-b bg-neutral-primary border-default">
429
+ <td class="px-6 py-4 font-medium">
430
+ <code class="text-fg-brand">prev()</code>
431
+ </td>
432
+ <td class="px-6 py-4">
433
+ Use this method to go to the previous slide of the carousel component.
434
+ </td>
435
+ </tr>
436
+ <tr class="border-b bg-neutral-primary border-default">
437
+ <td class="px-6 py-4 font-medium">
438
+ <code class="text-fg-brand">slideTo(position)</code>
439
+ </td>
440
+ <td class="px-6 py-4">
441
+ Use this method to go the carousel with the position that you set as a parameter.
442
+ </td>
443
+ </tr>
444
+ <tr class="border-b bg-neutral-primary border-default">
445
+ <td class="px-6 py-4 font-medium">
446
+ <code class="text-fg-brand">cycle()</code>
447
+ </td>
448
+ <td class="px-6 py-4">
449
+ Use this method to start cycling the carousel component based on the default interval duration.
450
+ </td>
451
+ </tr>
452
+ <tr class="border-b bg-neutral-primary border-default">
453
+ <td class="px-6 py-4 font-medium">
454
+ <code class="text-fg-brand">pause()</code>
455
+ </td>
456
+ <td class="px-6 py-4">
457
+ Use this method to stop the automatic cycling of the carousel component.
458
+ </td>
459
+ </tr>
460
+ <tr class="border-b bg-neutral-primary border-default">
461
+ <td class="px-6 py-4 font-medium">
462
+ <code class="text-fg-brand">getItem(position)</code>
463
+ </td>
464
+ <td class="px-6 py-4">
465
+ Get the carousel item based on the position number that you set as a parameter.
466
+ </td>
467
+ </tr>
468
+ <tr class="border-b bg-neutral-primary border-default">
469
+ <td class="px-6 py-4 font-medium">
470
+ <code class="text-fg-brand">getActiveItem()</code>
471
+ </td>
472
+ <td class="px-6 py-4">
473
+ Get the current active carousel item.
474
+ </td>
475
+ </tr>
476
+ <tr class="border-b bg-neutral-primary border-default">
477
+ <td class="px-6 py-4 font-medium">
478
+ <code class="text-fg-brand">updateOnNext(callback)</code>
479
+ </td>
480
+ <td class="px-6 py-4">
481
+ Set a callback function when the next carousel item has been shown.
482
+ </td>
483
+ </tr>
484
+ <tr class="border-b bg-neutral-primary border-default">
485
+ <td class="px-6 py-4 font-medium">
486
+ <code class="text-fg-brand">updateOnPrev(callback)</code>
487
+ </td>
488
+ <td class="px-6 py-4">
489
+ Set a callback function when the previous carousel item has been shown.
490
+ </td>
491
+ </tr>
492
+ <tr class="bg-neutral-primary">
493
+ <td class="px-6 py-4 font-medium">
494
+ <code class="text-fg-brand">updateOnChange(callback)</code>
495
+ </td>
496
+ <td class="px-6 py-4">
497
+ Set a callback function when the the slide item inside the carousel has been changed.
498
+ </td>
499
+ </tr>
500
+ </tbody>
501
+ </table>
502
+ </div>
503
+
504
+ ### Example
505
+
506
+ Check out the following example to learn how to programmatically create a new Carousel object by passing the parameters, using the methods, and the callback functions.
507
+
508
+ {{< code lang="javascript" file="carousel.js" icon="file" >}}
509
+ const carouselElement = document.getElementById('carousel-example');
510
+
511
+ const items = [
512
+ {
513
+ position: 0,
514
+ el: document.getElementById('carousel-item-1'),
515
+ },
516
+ {
517
+ position: 1,
518
+ el: document.getElementById('carousel-item-2'),
519
+ },
520
+ {
521
+ position: 2,
522
+ el: document.getElementById('carousel-item-3'),
523
+ },
524
+ {
525
+ position: 3,
526
+ el: document.getElementById('carousel-item-4'),
527
+ },
528
+ ];
529
+
530
+ // options with default values
531
+ const options = {
532
+ defaultPosition: 1,
533
+ interval: 3000,
534
+
535
+ indicators: {
536
+ activeClasses: 'bg-white dark:bg-gray-800',
537
+ inactiveClasses:
538
+ 'bg-white/50 dark:bg-gray-800/50 hover:bg-white dark:hover:bg-gray-800',
539
+ items: [
540
+ {
541
+ position: 0,
542
+ el: document.getElementById('carousel-indicator-1'),
543
+ },
544
+ {
545
+ position: 1,
546
+ el: document.getElementById('carousel-indicator-2'),
547
+ },
548
+ {
549
+ position: 2,
550
+ el: document.getElementById('carousel-indicator-3'),
551
+ },
552
+ {
553
+ position: 3,
554
+ el: document.getElementById('carousel-indicator-4'),
555
+ },
556
+ ],
557
+ },
558
+
559
+ // callback functions
560
+ onNext: () => {
561
+ console.log('next slider item is shown');
562
+ },
563
+ onPrev: () => {
564
+ console.log('previous slider item is shown');
565
+ },
566
+ onChange: () => {
567
+ console.log('new slider item has been shown');
568
+ },
569
+ };
570
+
571
+ // instance options object
572
+ const instanceOptions = {
573
+ id: 'carousel-example',
574
+ override: true
575
+ };
576
+ {{< /code >}}
577
+
578
+ Create a new carousel object using the options set above.
579
+
580
+ {{< code lang="javascript" file="carousel.js" icon="file" >}}
581
+ import { Carousel } from 'flowbite';
582
+
583
+ const carousel = new Carousel(carouselElement, items, options, instanceOptions);
584
+ {{< /code >}}
585
+
586
+ Use the `next()` and `prev()` public methods on the carousel object to jump to the left or right carousel slide item based on the position of the current active item.
587
+
588
+ {{< code lang="javascript" file="carousel.js" icon="file" >}}
589
+ // goes to the next (right) slide
590
+ carousel.next();
591
+
592
+ // goes to the previous (left) slide
593
+ carousel.prev();
594
+ {{< /code >}}
595
+
596
+ Use the `slideTo(position)` public method to jump to the carousel slide item with the specified position.
597
+
598
+ {{< code lang="javascript" file="carousel.js" icon="file" >}}
599
+ // jumps to the 3rd position (position starts from 0)
600
+ carousel.slideTo(2);
601
+ {{< /code >}}
602
+
603
+ Use the `cycle()` method to start an automated cycling where the duration is the milliseconds of time between each slide and the `pause()` method to clear the cycle event.
604
+
605
+ {{< code lang="javascript" file="carousel.js" icon="file" >}}
606
+ // starts or resumes the carousel cycling (automated sliding)
607
+ carousel.cycle();
608
+
609
+ // pauses the cycling (automated sliding)
610
+ carousel.pause();
611
+ {{< /code >}}
612
+
613
+ ### HTML Markup
614
+
615
+ Here is an example of the HTML markup that you can use for the JavaScript example above. Please note that you should use the `hidden` class from Tailwind CSS to hide the carousel items by default.
616
+
617
+ {{< code lang="html" file="carousel.html" icon="file" >}}
618
+ <div id="carousel-example" class="relative w-full">
619
+ <!-- Carousel wrapper -->
620
+ <div
621
+ class="relative h-56 overflow-hidden rounded-base sm:h-64 xl:h-80 2xl:h-96"
622
+ >
623
+ <!-- Item 1 -->
624
+ <div id="carousel-item-1" class="hidden duration-700 ease-in-out">
625
+ <img
626
+ src="/docs/images/carousel/carousel-1.svg"
627
+ class="absolute left-1/2 top-1/2 block w-full -translate-x-1/2 -translate-y-1/2"
628
+ alt="..."
629
+ />
630
+ </div>
631
+ <!-- Item 2 -->
632
+ <div id="carousel-item-2" class="hidden duration-700 ease-in-out">
633
+ <img
634
+ src="/docs/images/carousel/carousel-2.svg"
635
+ class="absolute left-1/2 top-1/2 block w-full -translate-x-1/2 -translate-y-1/2"
636
+ alt="..."
637
+ />
638
+ </div>
639
+ <!-- Item 3 -->
640
+ <div id="carousel-item-3" class="hidden duration-700 ease-in-out">
641
+ <img
642
+ src="/docs/images/carousel/carousel-3.svg"
643
+ class="absolute left-1/2 top-1/2 block w-full -translate-x-1/2 -translate-y-1/2"
644
+ alt="..."
645
+ />
646
+ </div>
647
+ <!-- Item 4 -->
648
+ <div id="carousel-item-4" class="hidden duration-700 ease-in-out">
649
+ <img
650
+ src="/docs/images/carousel/carousel-4.svg"
651
+ class="absolute left-1/2 top-1/2 block w-full -translate-x-1/2 -translate-y-1/2"
652
+ alt="..."
653
+ />
654
+ </div>
655
+ </div>
656
+ <!-- Slider indicators -->
657
+ <div
658
+ class="absolute bottom-5 left-1/2 z-30 flex -translate-x-1/2 space-x-3 rtl:space-x-reverse"
659
+ >
660
+ <button
661
+ id="carousel-indicator-1"
662
+ type="button"
663
+ class="h-3 w-3 rounded-base"
664
+ aria-current="true"
665
+ aria-label="Slide 1"
666
+ ></button>
667
+ <button
668
+ id="carousel-indicator-2"
669
+ type="button"
670
+ class="h-3 w-3 rounded-base"
671
+ aria-current="false"
672
+ aria-label="Slide 2"
673
+ ></button>
674
+ <button
675
+ id="carousel-indicator-3"
676
+ type="button"
677
+ class="h-3 w-3 rounded-base"
678
+ aria-current="false"
679
+ aria-label="Slide 3"
680
+ ></button>
681
+ <button
682
+ id="carousel-indicator-4"
683
+ type="button"
684
+ class="h-3 w-3 rounded-base"
685
+ aria-current="false"
686
+ aria-label="Slide 4"
687
+ ></button>
688
+ </div>
689
+ <!-- Slider controls -->
690
+ <button
691
+ id="data-carousel-prev"
692
+ type="button"
693
+ class="group absolute left-0 top-0 z-30 flex h-full cursor-pointer items-center justify-center px-4 focus:outline-none"
694
+ >
695
+ <span
696
+ class="inline-flex h-10 w-10 items-center justify-center rounded-base bg-white/30 group-hover:bg-white/50 group-focus:outline-none group-focus:ring-4 group-focus:ring-white dark:bg-gray-800/30 dark:group-hover:bg-gray-800/60 dark:group-focus:ring-gray-800/70"
697
+ >
698
+ <svg
699
+ class="h-4 w-4 text-white dark:text-gray-800"
700
+ aria-hidden="true"
701
+ xmlns="http://www.w3.org/2000/svg"
702
+ fill="none"
703
+ viewBox="0 0 6 10"
704
+ >
705
+ <path
706
+ stroke="currentColor"
707
+ stroke-linecap="round"
708
+ stroke-linejoin="round"
709
+ stroke-width="2"
710
+ d="M5 1 1 5l4 4"
711
+ />
712
+ </svg>
713
+ <span class="hidden">Previous</span>
714
+ </span>
715
+ </button>
716
+ <button
717
+ id="data-carousel-next"
718
+ type="button"
719
+ class="group absolute right-0 top-0 z-30 flex h-full cursor-pointer items-center justify-center px-4 focus:outline-none"
720
+ >
721
+ <span
722
+ class="inline-flex h-10 w-10 items-center justify-center rounded-base bg-white/30 group-hover:bg-white/50 group-focus:outline-none group-focus:ring-4 group-focus:ring-white dark:bg-gray-800/30 dark:group-hover:bg-gray-800/60 dark:group-focus:ring-gray-800/70"
723
+ >
724
+ <svg
725
+ class="h-4 w-4 text-white dark:text-gray-800"
726
+ aria-hidden="true"
727
+ xmlns="http://www.w3.org/2000/svg"
728
+ fill="none"
729
+ viewBox="0 0 6 10"
730
+ >
731
+ <path
732
+ stroke="currentColor"
733
+ stroke-linecap="round"
734
+ stroke-linejoin="round"
735
+ stroke-width="2"
736
+ d="m1 9 4-4-4-4"
737
+ />
738
+ </svg>
739
+ <span class="hidden">Next</span>
740
+ </span>
741
+ </button>
742
+ </div>
743
+ {{< /code >}}
744
+
745
+ If you want to set trigger the next or previous slide item for the any button, just add some event listeners and call the `next()` and `prev()` methods on the Carousel object.
746
+
747
+ {{< code lang="javascript" file="carousel.js" icon="file" >}}
748
+ const $prevButton = document.getElementById('data-carousel-prev');
749
+ const $nextButton = document.getElementById('data-carousel-next');
750
+
751
+ $prevButton.addEventListener('click', () => {
752
+ carousel.prev();
753
+ });
754
+
755
+ $nextButton.addEventListener('click', () => {
756
+ carousel.next();
757
+ });
758
+ {{< /code >}}
759
+
760
+ ### TypeScript
761
+
762
+ If you're using the <a href="{{< ref "getting-started/typescript" >}}">TypeScript configuration</a> from Flowbite then you can import the types for the Carousel class, parameters and its options.
763
+
764
+ Here's an example that applies the types from Flowbite to the code above:
765
+
766
+ {{< code lang="typescript" file="carousel.ts" icon="file" >}}
767
+ import { Carousel } from 'flowbite';
768
+ import type {
769
+ CarouselItem,
770
+ CarouselOptions,
771
+ CarouselInterface,
772
+ } from 'flowbite';
773
+ import type { InstanceOptions } from 'flowbite';
774
+
775
+ const carouselElement: HTMLElement = document.getElementById('carousel-example');
776
+
777
+ const items: CarouselItem[] = [
778
+ {
779
+ position: 0,
780
+ el: document.getElementById('carousel-item-1'),
781
+ },
782
+ {
783
+ position: 1,
784
+ el: document.getElementById('carousel-item-2'),
785
+ },
786
+ {
787
+ position: 2,
788
+ el: document.getElementById('carousel-item-3'),
789
+ },
790
+ {
791
+ position: 3,
792
+ el: document.getElementById('carousel-item-4'),
793
+ },
794
+ ];
795
+
796
+ // object options with default values
797
+ const options: CarouselOptions = {
798
+ defaultPosition: 1,
799
+ interval: 3000,
800
+
801
+ indicators: {
802
+ activeClasses: 'bg-white dark:bg-gray-800',
803
+ inactiveClasses:
804
+ 'bg-white/50 dark:bg-gray-800/50 hover:bg-white dark:hover:bg-gray-800',
805
+ items: [
806
+ {
807
+ position: 0,
808
+ el: document.getElementById('carousel-indicator-1'),
809
+ },
810
+ {
811
+ position: 1,
812
+ el: document.getElementById('carousel-indicator-2'),
813
+ },
814
+ {
815
+ position: 2,
816
+ el: document.getElementById('carousel-indicator-3'),
817
+ },
818
+ {
819
+ position: 3,
820
+ el: document.getElementById('carousel-indicator-4'),
821
+ },
822
+ ],
823
+ },
824
+
825
+ // callback functions
826
+ onNext: () => {
827
+ console.log('next slider item is shown');
828
+ },
829
+ onPrev: () => {
830
+ console.log('previous slider item is shown');
831
+ },
832
+ onChange: () => {
833
+ console.log('new slider item has been shown');
834
+ },
835
+ };
836
+
837
+ // instance options object
838
+ const instanceOptions: InstanceOptions = {
839
+ id: 'carousel-example',
840
+ override: true
841
+ };
842
+
843
+ const carousel: CarouselInterface = new Carousel(carouselElement, items, options, instanceOptions);
844
+
845
+ carousel.cycle();
846
+
847
+ // set event listeners for prev and next buttons
848
+ const $prevButton = document.getElementById('data-carousel-prev');
849
+ const $nextButton = document.getElementById('data-carousel-next');
850
+
851
+ $prevButton.addEventListener('click', () => {
852
+ carousel.prev();
853
+ });
854
+
855
+ $nextButton.addEventListener('click', () => {
856
+ carousel.next();
857
+ });
858
+ {{< /code >}}