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,860 @@
1
+ ---
2
+ layout: docs
3
+ title: Tailwind CSS Accordion - Flowbite
4
+ description: Use the accordion component to show hidden information based on the collapse and expand state of the child elements using data attribute options
5
+ group: components
6
+ toc: true
7
+ requires_js: true
8
+
9
+ previous: RTL (Right-To-Left)
10
+ previousLink: customize/rtl/
11
+ next: Alerts
12
+ nextLink: components/alerts/
13
+ ---
14
+
15
+ The accordion component is a collection of vertically collapsing header and body elements that can be used to show and hide information based on the Tailwind CSS utility classes and JavaScript from Flowbite.
16
+
17
+ A popular use case would be the "Frequently Asked Questions" section of a website or page when you can show questions and answers for each child element.
18
+
19
+ There are two main options to initialize the accordion component:
20
+
21
+ - `data-accordion="collapse"` show only one active child element
22
+ - `data-accordion="open"` keep multiple elements open
23
+
24
+ Don't forget to set the `data-accordion-target="{selector}"` data attribute to the header element where the value is the id or class of the accordion body element and the `aria-expanded="{true|false}"` attribute to mark the active or inactive state of the accordion.
25
+
26
+ ## Default accordion
27
+
28
+ Use the `data-accordion="collapse"` to collapse every other child element when expanding a single one.
29
+
30
+ {{< example github="components/accordion.md" show_dark=true >}}
31
+ <div id="accordion-collapse" data-accordion="collapse" class="rounded-base border border-default overflow-hidden shadow-xs">
32
+ <h2 id="accordion-collapse-heading-1">
33
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-t-base border border-t-0 border-x-0 border-b-default hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-collapse-body-1" aria-expanded="true" aria-controls="accordion-collapse-body-1">
34
+ <span>What is Flowbite?</span>
35
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
36
+ </button>
37
+ </h2>
38
+ <div id="accordion-collapse-body-1" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-collapse-heading-1">
39
+ <div class="p-4 md:p-5">
40
+ <p class="mb-2 text-body">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
41
+ <p class="text-body">Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
42
+ </div>
43
+ </div>
44
+ <h2 id="accordion-collapse-heading-2">
45
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body border border-x-0 border-b-default border-t-0 hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-collapse-body-2" aria-expanded="false" aria-controls="accordion-collapse-body-2">
46
+ <span>Is there a Figma file available?</span>
47
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
48
+ </button>
49
+ </h2>
50
+ <div id="accordion-collapse-body-2" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-collapse-heading-2">
51
+ <div class="p-4 md:p-5">
52
+ <p class="mb-2 text-body">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
53
+ <p class="text-body">Check out the <a href="{{< param homepage >}}/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
54
+ </div>
55
+ </div>
56
+ <h2 id="accordion-collapse-heading-3">
57
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-collapse-body-3" aria-expanded="false" aria-controls="accordion-collapse-body-3">
58
+ <span>What are the differences between Flowbite and Tailwind UI?</span>
59
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
60
+ </button>
61
+ </h2>
62
+ <div id="accordion-collapse-body-3" class="hidden" aria-labelledby="accordion-collapse-heading-3">
63
+ <div class="p-4 md:p-5 border border-t-default border-b-0 border-x-0">
64
+ <p class="mb-2 text-body">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
65
+ <p class="mb-2 text-body">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
66
+ <p class="mb-2 text-body">Learn more about these technologies:</p>
67
+ <ul class="ps-5 text-body list-disc">
68
+ <li><a href="{{< param homepage >}}/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
69
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
70
+ </ul>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ {{< /example >}}
75
+
76
+ ## Separated cards
77
+
78
+ Use this example of an accordion with space delimitation between the accordion items.
79
+
80
+ {{< example github="components/accordion.md" show_dark=true >}}
81
+ <div id="accordion-card" data-accordion="collapse">
82
+ <h2 id="accordion-card-heading-1">
83
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-base shadow-xs border border-default hover:text-heading hover:bg-neutral-secondary-medium gap-3 [&[aria-expanded='true']]:rounded-b-none [&[aria-expanded='true']]:shadow-none" data-accordion-target="#accordion-card-body-1" aria-expanded="true" aria-controls="accordion-card-body-1">
84
+ <span>What is Flowbite?</span>
85
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
86
+ </button>
87
+ </h2>
88
+ <div id="accordion-card-body-1" class="hidden border border-t-0 border-default rounded-b-base shadow-xs" aria-labelledby="accordion-card-heading-1">
89
+ <div class="p-4 md:p-5">
90
+ <p class="mb-2 text-body">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
91
+ <p class="text-body">Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
92
+ </div>
93
+ </div>
94
+ <h2 id="accordion-card-heading-2" class="mt-4">
95
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-base shadow-xs border border-default hover:text-heading hover:bg-neutral-secondary-medium gap-3 [&[aria-expanded='true']]:rounded-b-none [&[aria-expanded='true']]:shadow-none" data-accordion-target="#accordion-card-body-2" aria-expanded="false" aria-controls="accordion-card-body-2">
96
+ <span>Is there a Figma file available?</span>
97
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
98
+ </button>
99
+ </h2>
100
+ <div id="accordion-card-body-2" class="hidden border border-t-0 border-default rounded-b-base shadow-xs" aria-labelledby="accordion-card-heading-2">
101
+ <div class="p-4 md:p-5">
102
+ <p class="mb-2 text-body">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
103
+ <p class="text-body">Check out the <a href="{{< param homepage >}}/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
104
+ </div>
105
+ </div>
106
+ <h2 id="accordion-card-heading-3" class="mt-4">
107
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-base shadow-xs border border-default hover:text-heading hover:bg-neutral-secondary-medium gap-3 [&[aria-expanded='true']]:rounded-b-none [&[aria-expanded='true']]:shadow-none" data-accordion-target="#accordion-card-body-3" aria-expanded="false" aria-controls="accordion-card-body-3">
108
+ <span>What are the differences between Flowbite and Tailwind UI?</span>
109
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
110
+ </button>
111
+ </h2>
112
+ <div id="accordion-card-body-3" class="hidden border border-t-0 border-default rounded-b-base shadow-xs" aria-labelledby="accordion-card-heading-3">
113
+ <div class="p-4 md:p-5">
114
+ <p class="mb-2 text-body">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
115
+ <p class="mb-2 text-body">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
116
+ <p class="mb-2 text-body">Learn more about these technologies:</p>
117
+ <ul class="ps-5 text-body list-disc">
118
+ <li><a href="{{< param homepage >}}/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
119
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
120
+ </ul>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ {{< /example >}}
125
+
126
+ ## Always open
127
+
128
+ Use the `data-accordion="open"` option to keep previously opened accordion elements unchanged.
129
+
130
+ {{< example github="components/accordion.md" show_dark=true >}}
131
+ <div id="accordion-open" data-accordion="open" class="rounded-base border border-default overflow-hidden shadow-xs">
132
+ <h2 id="accordion-open-heading-1">
133
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-t-base border border-t-0 border-x-0 border-b-default hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-open-body-1" aria-expanded="true" aria-controls="accordion-open-body-1">
134
+ <span class="flex items-center"><svg class="w-5 h-5 me-2 shrink-0" 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.529 9.988a2.502 2.502 0 1 1 5 .191A2.441 2.441 0 0 1 12 12.582V14m-.01 3.008H12M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/></svg>What is Flowbite?</span>
135
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
136
+ </button>
137
+ </h2>
138
+ <div id="accordion-open-body-1" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-open-heading-1">
139
+ <div class="p-4 md:p-5">
140
+ <p class="mb-2 text-body">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
141
+ <p class="text-body">Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
142
+ </div>
143
+ </div>
144
+ <h2 id="accordion-open-heading-2">
145
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body border border-x-0 border-b-default border-t-0 hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-open-body-2" aria-expanded="false" aria-controls="accordion-open-body-2">
146
+ <span class="flex items-center"><svg class="w-5 h-5 me-2 shrink-0" 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.529 9.988a2.502 2.502 0 1 1 5 .191A2.441 2.441 0 0 1 12 12.582V14m-.01 3.008H12M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/></svg>Is there a Figma file available?</span>
147
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
148
+ </button>
149
+ </h2>
150
+ <div id="accordion-open-body-2" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-open-heading-2">
151
+ <div class="p-4 md:p-5">
152
+ <p class="mb-2 text-body">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
153
+ <p class="text-body">Check out the <a href="{{< param homepage >}}/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
154
+ </div>
155
+ </div>
156
+ <h2 id="accordion-open-heading-3">
157
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-open-body-3" aria-expanded="false" aria-controls="accordion-open-body-3">
158
+ <span class="flex items-center"><svg class="w-5 h-5 me-2 shrink-0" 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.529 9.988a2.502 2.502 0 1 1 5 .191A2.441 2.441 0 0 1 12 12.582V14m-.01 3.008H12M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/></svg> What are the differences between Flowbite and Tailwind UI?</span>
159
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
160
+ </button>
161
+ </h2>
162
+ <div id="accordion-open-body-3" class="hidden" aria-labelledby="accordion-open-heading-3">
163
+ <div class="p-4 md:p-5 border border-t-default border-b-0 border-x-0">
164
+ <p class="mb-2 text-body">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
165
+ <p class="mb-2 text-body">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
166
+ <p class="mb-2 text-body">Learn more about these technologies:</p>
167
+ <ul class="ps-5 text-body list-disc">
168
+ <li><a href="{{< param homepage >}}/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
169
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
170
+ </ul>
171
+ </div>
172
+ </div>
173
+ </div>
174
+ {{< /example >}}
175
+
176
+ ## Color options
177
+
178
+ Use the `data-active-classes` and `data-inactive-classes` to set the active and inactive classes for the header element whenever the accordion is expanded by applying as many classes as you want, but make sure to separate them with a space. If the data attribute is not set or empty, it will apply the default classes.
179
+
180
+ Here's an example where we apply the blue colors instead of gray:
181
+
182
+ {{< example github="components/accordion.md" show_dark=true >}}
183
+ <div id="accordion-color" data-accordion="collapse" class="rounded-base border border-default overflow-hidden shadow-xs">
184
+ <h2 id="accordion-color-heading-1">
185
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-t-base border border-t-0 border-x-0 border-b-default hover:text-fg-brand hover:bg-brand-softer gap-3" data-accordion-target="#accordion-color-body-1" aria-expanded="true" aria-controls="accordion-color-body-1">
186
+ <span>What is Flowbite?</span>
187
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
188
+ </button>
189
+ </h2>
190
+ <div id="accordion-color-body-1" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-color-heading-1">
191
+ <div class="p-4 md:p-5">
192
+ <p class="mb-2 text-body">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
193
+ <p class="text-body">Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
194
+ </div>
195
+ </div>
196
+ <h2 id="accordion-color-heading-2">
197
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body border border-x-0 border-b-default border-t-0 hover:text-fg-brand hover:bg-brand-softer gap-3" data-accordion-target="#accordion-color-body-2" aria-expanded="false" aria-controls="accordion-color-body-2">
198
+ <span>Is there a Figma file available?</span>
199
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
200
+ </button>
201
+ </h2>
202
+ <div id="accordion-color-body-2" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-color-heading-2">
203
+ <div class="p-4 md:p-5">
204
+ <p class="mb-2 text-body">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
205
+ <p class="text-body">Check out the <a href="{{< param homepage >}}/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
206
+ </div>
207
+ </div>
208
+ <h2 id="accordion-color-heading-3">
209
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body hover:text-fg-brand hover:bg-brand-softer gap-3" data-accordion-target="#accordion-color-body-3" aria-expanded="false" aria-controls="accordion-color-body-3">
210
+ <span>What are the differences between Flowbite and Tailwind UI?</span>
211
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
212
+ </button>
213
+ </h2>
214
+ <div id="accordion-color-body-3" class="hidden" aria-labelledby="accordion-color-heading-3">
215
+ <div class="p-4 md:p-5 border border-t-default border-b-0 border-x-0">
216
+ <p class="mb-2 text-body">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
217
+ <p class="mb-2 text-body">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
218
+ <p class="mb-2 text-body">Learn more about these technologies:</p>
219
+ <ul class="ps-5 text-body list-disc">
220
+ <li><a href="{{< param homepage >}}/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
221
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
222
+ </ul>
223
+ </div>
224
+ </div>
225
+ </div>
226
+ {{< /example >}}
227
+
228
+ ## Flush accordion
229
+
230
+ Use this example to remove the background color and rounded borders from the accordion component.
231
+
232
+ {{< example github="components/accordion.md" show_dark=true >}}
233
+ <div id="accordion-flush" data-accordion="collapse" data-active-classes="bg-neutral-primary text-heading" data-inactive-classes="text-body">
234
+ <h2 id="accordion-flush-heading-1">
235
+ <button type="button" class="flex items-center justify-between w-full py-5 font-medium rtl:text-right text-body border-b border-default gap-3" data-accordion-target="#accordion-flush-body-1" aria-expanded="true" aria-controls="accordion-flush-body-1">
236
+ <span>What is Flowbite?</span>
237
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
238
+ </button>
239
+ </h2>
240
+ <div id="accordion-flush-body-1" class="hidden" aria-labelledby="accordion-flush-heading-1">
241
+ <div class="py-5 border-b border-default text-body">
242
+ <p class="mb-2">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
243
+ <p>Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
244
+ </div>
245
+ </div>
246
+ <h2 id="accordion-flush-heading-2">
247
+ <button type="button" class="flex items-center justify-between w-full py-5 font-medium rtl:text-right text-body border-b border-default gap-3" data-accordion-target="#accordion-flush-body-2" aria-expanded="false" aria-controls="accordion-flush-body-2">
248
+ <span>Is there a Figma file available?</span>
249
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
250
+ </button>
251
+ </h2>
252
+ <div id="accordion-flush-body-2" class="hidden" aria-labelledby="accordion-flush-heading-2">
253
+ <div class="py-5 border-b border-default text-body">
254
+ <p class="mb-2">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
255
+ <p>Check out the <a href="{{< param homepage >}}/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
256
+ </div>
257
+ </div>
258
+ <h2 id="accordion-flush-heading-3">
259
+ <button type="button" class="flex items-center justify-between w-full py-5 font-medium rtl:text-right text-body border-b border-default gap-3" data-accordion-target="#accordion-flush-body-3" aria-expanded="false" aria-controls="accordion-flush-body-3">
260
+ <span>What are the differences between Flowbite and Tailwind UI?</span>
261
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
262
+ </button>
263
+ </h2>
264
+ <div id="accordion-flush-body-3" class="hidden" aria-labelledby="accordion-flush-heading-3">
265
+ <div class="py-5 text-body border-b border-default">
266
+ <p class="mb-2">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
267
+ <p class="mb-2">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
268
+ <p class="mb-2">Learn more about these technologies:</p>
269
+ <ul class="ps-5 list-disc">
270
+ <li><a href="{{< param homepage >}}/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
271
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
272
+ </ul>
273
+ </div>
274
+ </div>
275
+ </div>
276
+ {{< /example >}}
277
+
278
+ ## Arrow style
279
+
280
+ Use the `data-accordion-icon` data attribute to optionally set an element to rotate 180 degrees when the accordion element is expanded. If the data attribute is not set, then it will not rotate.
281
+
282
+ {{< example github="components/accordion.md" show_dark=true >}}
283
+ <div id="accordion-arrow" data-accordion="collapse" data-active-classes="bg-neutral-primary text-heading" data-inactive-classes="text-body">
284
+ <h2 id="accordion-arrow-heading-1">
285
+ <button type="button" class="flex items-center justify-between w-full py-5 font-medium rtl:text-right text-body border-b border-default gap-3" data-accordion-target="#accordion-arrow-body-1" aria-expanded="true" aria-controls="accordion-arrow-body-1">
286
+ <span>Accordion without an arrow</span>
287
+ </button>
288
+ </h2>
289
+ <div id="accordion-arrow-body-1" class="hidden" aria-labelledby="accordion-arrow-heading-1">
290
+ <div class="py-5 border-b border-default text-body">
291
+ <p class="mb-2">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
292
+ <p>Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
293
+ </div>
294
+ </div>
295
+ <h2 id="accordion-arrow-heading-2">
296
+ <button type="button" class="flex items-center justify-between w-full py-5 font-medium rtl:text-right text-body border-b border-default gap-3" data-accordion-target="#accordion-arrow-body-2" aria-expanded="false" aria-controls="accordion-arrow-body-2">
297
+ <span>Accordion with another icon</span>
298
+ <svg class="w-5 h-5 shrink-0" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
299
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.529 9.988a2.502 2.502 0 1 1 5 .191A2.441 2.441 0 0 1 12 12.582V14m-.01 3.008H12M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/>
300
+ </svg>
301
+ </button>
302
+ </h2>
303
+ <div id="accordion-arrow-body-2" class="hidden" aria-labelledby="accordion-arrow-heading-2">
304
+ <div class="py-5 border-b border-default text-body">
305
+ <p class="mb-2">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
306
+ <p>Check out the <a href="{{< param homepage >}}/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
307
+ </div>
308
+ </div>
309
+ <h2 id="accordion-arrow-heading-3">
310
+ <button type="button" class="flex items-center justify-between w-full py-5 font-medium rtl:text-right text-body border-b border-default gap-3" data-accordion-target="#accordion-arrow-body-3" aria-expanded="false" aria-controls="accordion-arrow-body-3">
311
+ <span>Accordion without arrow rotation</span>
312
+ <svg class="w-5 h-5 shrink-0" 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="m19 9-7 7-7-7"/></svg>
313
+ </button>
314
+ </h2>
315
+ <div id="accordion-arrow-body-3" class="hidden" aria-labelledby="accordion-arrow-heading-3">
316
+ <div class="py-5 text-body border-b border-default">
317
+ <p class="mb-2">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
318
+ <p class="mb-2">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
319
+ <p class="mb-2">Learn more about these technologies:</p>
320
+ <ul class="ps-5 list-disc">
321
+ <li><a href="{{< param homepage >}}/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
322
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
323
+ </ul>
324
+ </div>
325
+ </div>
326
+ </div>
327
+ {{< /example >}}
328
+
329
+ ## Nesting accordions
330
+
331
+ Accordions can be nested. All of the mentioned options are supported.
332
+
333
+ To enable nested accordions you need to wrap the nested accordion in an element with the `data-accordion` attribute and don't accidentally initialize an accordion with nested accordions' items (e.g. by using `$accordionBodyEl.querySelectorAll`), when using <a href="#javascript-behaviour">custom JavaScript</a>.
334
+
335
+ {{< example github="components/accordion.md" show_dark=true >}}
336
+
337
+ <div id="accordion-collapse-2" data-accordion="collapse" class="rounded-base border border-default overflow-hidden shadow-xs">
338
+ <h2 id="accordion-collapse-heading-6">
339
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-t-base border border-t-0 border-x-0 border-b-default hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-collapse-body-6" aria-expanded="true" aria-controls="accordion-collapse-body-6">
340
+ <span>What is Flowbite?</span>
341
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
342
+ </button>
343
+ </h2>
344
+ <div id="accordion-collapse-body-6" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default p-4 md:p-5" aria-labelledby="accordion-collapse-heading-6">
345
+ <p class="mb-2 text-body">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
346
+ <p class="text-body mb-4">Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
347
+ <!-- Nested accordion -->
348
+ <div id="accordion-nested" data-accordion="collapse" class="rounded-base border border-default overflow-hidden shadow-xs">
349
+ <h2 id="accordion-nested-heading-1">
350
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body rounded-t-base border border-t-0 border-x-0 border-b-default hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-nested-body-1" aria-expanded="true" aria-controls="accordion-nested-body-1">
351
+ <span>What is Flowbite?</span>
352
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
353
+ </button>
354
+ </h2>
355
+ <div id="accordion-nested-body-1" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-nested-heading-1">
356
+ <div class="p-4 md:p-5">
357
+ <p class="mb-2 text-body">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
358
+ <p class="text-body">Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
359
+ </div>
360
+ </div>
361
+ <h2 id="accordion-nested-heading-2">
362
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body border border-x-0 border-b-default border-t-0 bg-neutral-primary-soft hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-nested-body-2" aria-expanded="false" aria-controls="accordion-nested-body-2">
363
+ <span>Is there a Figma file available?</span>
364
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
365
+ </button>
366
+ </h2>
367
+ <div id="accordion-nested-body-2" class="hidden border border-s-0 border-e-0 border-t-0 border-b-default" aria-labelledby="accordion-nested-heading-2">
368
+ <div class="p-4 md:p-5">
369
+ <p class="mb-2 text-body">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
370
+ <p class="text-body">Check out the <a href="https://flowbite.com/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
371
+ </div>
372
+ </div>
373
+ <h2 id="accordion-nested-heading-3">
374
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body bg-neutral-primary-soft hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-nested-body-3" aria-expanded="false" aria-controls="accordion-nested-body-3">
375
+ <span>What are the differences between Flowbite and Tailwind UI?</span>
376
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
377
+ </button>
378
+ </h2>
379
+ <div id="accordion-nested-body-3" class="hidden" aria-labelledby="accordion-nested-heading-3">
380
+ <div class="p-4 md:p-5 border border-t-default border-b-0 border-x-0">
381
+ <p class="mb-2 text-body">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
382
+ <p class="mb-2 text-body">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
383
+ <p class="mb-2 text-body">Learn more about these technologies:</p>
384
+ <ul class="text-body ps-5 list-disc">
385
+ <li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
386
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
387
+ </ul>
388
+ </div>
389
+ </div>
390
+ </div>
391
+ <!-- End of Nested accordion -->
392
+ </div>
393
+ <h2 id="accordion-collapse-heading-7">
394
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body bg-neutral-primary-soft hover:text-heading hover:bg-neutral-secondary-medium gap-3" data-accordion-target="#accordion-collapse-body-7" aria-expanded="false" aria-controls="accordion-collapse-body-7">
395
+ <span>What are the differences between Flowbite and Tailwind UI?</span>
396
+ <svg data-accordion-icon class="w-5 h-5 rotate-180 shrink-0" 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="m5 15 7-7 7 7"/></svg>
397
+ </button>
398
+ </h2>
399
+ <div id="accordion-collapse-body-7" class="hidden" aria-labelledby="accordion-collapse-heading-7">
400
+ <div class="p-4 md:p-5 border border-t-default border-b-0 border-x-0">
401
+ <p class="mb-2 text-body">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
402
+ <p class="mb-2 text-body">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
403
+ <p class="mb-2 text-body">Learn more about these technologies:</p>
404
+ <ul class="text-body list-disc ps-5">
405
+ <li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
406
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
407
+ </ul>
408
+ </div>
409
+ </div>
410
+ </div>
411
+ {{< /example >}}
412
+
413
+ ## JavaScript behaviour
414
+
415
+ Use the **Accordion** object from Flowbite to create a collection of vertically collapsing heading and content elements using object parameters, options, methods, and callback functions directly from JavaScript.
416
+
417
+ ### Object parameters
418
+
419
+ Create a new Accordion object by passing an array of accordion items and an optional options object to customize the styles and add callback functions.
420
+
421
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
422
+ <table class="w-full text-sm rtl:text-right text-body">
423
+ <thead class="bg-neutral-secondary-soft text-heading">
424
+ <tr class="text-xs font-medium uppercase">
425
+ <th scope="col" class="px-6 py-3">
426
+ Parameter
427
+ </th>
428
+ <th scope="col" class="px-6 py-3">
429
+ Type
430
+ </th>
431
+ <th scope="col" class="px-6 py-3">
432
+ Required
433
+ </th>
434
+ <th scope="col" class="px-6 py-3">
435
+ Description
436
+ </th>
437
+ </tr>
438
+ </thead>
439
+ <tbody>
440
+ <tr class="border-b bg-neutral-primary border-default">
441
+ <td class="px-6 py-4 font-medium">
442
+ <code class="text-fg-brand">accordionEl</code>
443
+ </td>
444
+ <td class="px-6 py-4">
445
+ Element
446
+ </td>
447
+ <td class="px-6 py-4">
448
+ Required
449
+ </td>
450
+ <td class="px-6 py-4">
451
+ The parent HTML element of the accordion component.
452
+ </td>
453
+ </tr>
454
+ <tr class="border-b bg-neutral-primary border-default">
455
+ <td class="px-6 py-4 font-medium">
456
+ <code class="text-fg-brand">items</code>
457
+ </td>
458
+ <td class="px-6 py-4">
459
+ Array
460
+ </td>
461
+ <td class="px-6 py-4">
462
+ Required
463
+ </td>
464
+ <td class="px-6 py-4">
465
+ Array of accordion items objects including the unique identifier, heading element, content element, and the active state.
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">options</code>
471
+ </td>
472
+ <td class="px-6 py-4">
473
+ Object
474
+ </td>
475
+ <td class="px-6 py-4">
476
+ Optional
477
+ </td>
478
+ <td class="px-6 py-4">
479
+ Object of options that you can set to customize the style of the accordion items and set callback functions.
480
+ </td>
481
+ </tr>
482
+ <tr class="bg-neutral-primary">
483
+ <td class="px-6 py-4 font-medium">
484
+ <code class="text-fg-brand">instanceOptions</code>
485
+ </td>
486
+ <td class="px-6 py-4">
487
+ Object
488
+ </td>
489
+ <td class="px-6 py-4">
490
+ Optional
491
+ </td>
492
+ <td class="px-6 py-4">
493
+ 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.
494
+ </td>
495
+ </tr>
496
+ </tbody>
497
+ </table>
498
+ </div>
499
+
500
+ ### Options
501
+
502
+ Use the following options as the second parameter for the Accordion object to customize the behaviour, styles, and to set callback functions.
503
+
504
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
505
+ <table class="w-full text-sm rtl:text-right text-body">
506
+ <thead class="bg-neutral-secondary-soft text-heading">
507
+ <tr class="text-xs font-medium uppercase">
508
+ <th scope="col" class="px-6 py-3">
509
+ Option
510
+ </th>
511
+ <th scope="col" class="px-6 py-3">
512
+ Type
513
+ </th>
514
+ <th scope="col" class="px-6 py-3">
515
+ Description
516
+ </th>
517
+ </tr>
518
+ </thead>
519
+ <tbody>
520
+ <tr class="border-b bg-neutral-primary border-default">
521
+ <td class="px-6 py-4 font-medium">
522
+ <code class="text-fg-brand">alwaysOpen</code>
523
+ </td>
524
+ <td class="px-6 py-4">
525
+ Boolean
526
+ </td>
527
+ <td class="px-6 py-4">
528
+ If set to true then multiple accordion elements can be open at the same time. By default it's false.
529
+ </td>
530
+ </tr>
531
+ <tr class="border-b bg-neutral-primary border-default">
532
+ <td class="px-6 py-4 font-medium">
533
+ <code class="text-fg-brand">activeClasses</code>
534
+ </td>
535
+ <td class="px-6 py-4">
536
+ Array
537
+ </td>
538
+ <td class="px-6 py-4">
539
+ Set an array of Tailwind CSS class names to apply for the active accordion heading element.
540
+ </td>
541
+ </tr>
542
+ <tr class="border-b bg-neutral-primary border-default">
543
+ <td class="px-6 py-4 font-medium">
544
+ <code class="text-fg-brand">inactiveClasses</code>
545
+ </td>
546
+ <td class="px-6 py-4">
547
+ Array
548
+ </td>
549
+ <td class="px-6 py-4">
550
+ Apply an array of Tailwind CSS class names to apply for the inactive accordion heading elements.
551
+ </td>
552
+ </tr>
553
+ <tr class="border-b bg-neutral-primary border-default">
554
+ <td class="px-6 py-4 font-medium">
555
+ <code class="text-fg-brand">onOpen</code>
556
+ </td>
557
+ <td class="px-6 py-4">
558
+ Function
559
+ </td>
560
+ <td class="px-6 py-4">
561
+ Set a callback function when a new accordion item has been opened.
562
+ </td>
563
+ </tr>
564
+ <tr class="bg-neutral-primary">
565
+ <td class="px-6 py-4 font-medium">
566
+ <code class="text-fg-brand">onClose</code>
567
+ </td>
568
+ <td class="px-6 py-4">
569
+ Function
570
+ </td>
571
+ <td class="px-6 py-4">
572
+ Set a callback function when a new accordion item has been closed.
573
+ </td>
574
+ </tr>
575
+ </tbody>
576
+ </table>
577
+ </div>
578
+
579
+ ### Methods
580
+
581
+ Use the object methods on the Accordion object to programmatically open, close, or toggle the visibility of a given accordion item.
582
+
583
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
584
+ <table class="w-full text-sm rtl:text-right text-body">
585
+ <thead class="bg-neutral-secondary-soft text-heading">
586
+ <tr class="text-xs font-medium uppercase">
587
+ <th scope="col" class="px-6 py-3">
588
+ Method
589
+ </th>
590
+ <th scope="col" class="px-6 py-3">
591
+ Description
592
+ </th>
593
+ </tr>
594
+ </thead>
595
+ <tbody>
596
+ <tr class="border-b bg-neutral-primary border-default">
597
+ <td class="px-6 py-4 font-medium">
598
+ <code class="text-fg-brand">toggle(id)</code>
599
+ </td>
600
+ <td class="px-6 py-4">
601
+ Use this function to toggle an accordion item based on its current state.
602
+ </td>
603
+ </tr>
604
+ <tr class="border-b bg-neutral-primary border-default">
605
+ <td class="px-6 py-4 font-medium">
606
+ <code class="text-fg-brand">open(id)</code>
607
+ </td>
608
+ <td class="px-6 py-4">
609
+ Use this function to open an accordion item based on the id.
610
+ </td>
611
+ </tr>
612
+ <tr class="border-b bg-neutral-primary border-default">
613
+ <td class="px-6 py-4 font-medium">
614
+ <code class="text-fg-brand">close(id)</code>
615
+ </td>
616
+ <td class="px-6 py-4">
617
+ Use this function to close an accordion item based on the id.
618
+ </td>
619
+ </tr>
620
+ <tr class="border-b bg-neutral-primary border-default">
621
+ <td class="px-6 py-4 font-medium">
622
+ <code class="text-fg-brand">updateOnOpen(callback)</code>
623
+ </td>
624
+ <td class="px-6 py-4">
625
+ Use this method to set a callback function when an accordion item has been opened.
626
+ </td>
627
+ </tr>
628
+ <tr class="border-b bg-neutral-primary border-default">
629
+ <td class="px-6 py-4 font-medium">
630
+ <code class="text-fg-brand">updateOnClose(callback)</code>
631
+ </td>
632
+ <td class="px-6 py-4">
633
+ Use this method to set a callback function when an accordion item has been closed.
634
+ </td>
635
+ </tr>
636
+ <tr class="bg-neutral-primary">
637
+ <td class="px-6 py-4 font-medium">
638
+ <code class="text-fg-brand">updateOnToggle(callback)</code>
639
+ </td>
640
+ <td class="px-6 py-4">
641
+ Use this method to set a callback function when an accordion item has been toggled.
642
+ </td>
643
+ </tr>
644
+ </tbody>
645
+ </table>
646
+ </div>
647
+
648
+ ### Example
649
+
650
+ Learn more about using the Accordion object from Flowbite in this example in JavaScript.
651
+
652
+ To get started you need to create an array of accordion item objects including a unique identifier (it can be a number as well), a trigger element (eg. a button), a content element (the content body), and the active state.
653
+
654
+ Additionally, you can also set some options to change the default behaviour of the accordion, customize the styles, and set callback functions.
655
+
656
+ {{< code lang="javascript" file="accordion.js" icon="file" >}}
657
+ const accordionElement = document.getElementById('accordion-example');
658
+
659
+ // create an array of objects with the id, trigger element (eg. button), and the content element
660
+ const accordionItems = [
661
+ {
662
+ id: 'accordion-example-heading-1',
663
+ triggerEl: document.querySelector('#accordion-example-heading-1'),
664
+ targetEl: document.querySelector('#accordion-example-body-1'),
665
+ active: true
666
+ },
667
+ {
668
+ id: 'accordion-example-heading-2',
669
+ triggerEl: document.querySelector('#accordion-example-heading-2'),
670
+ targetEl: document.querySelector('#accordion-example-body-2'),
671
+ active: false
672
+ },
673
+ {
674
+ id: 'accordion-example-heading-3',
675
+ triggerEl: document.querySelector('#accordion-example-heading-3'),
676
+ targetEl: document.querySelector('#accordion-example-body-3'),
677
+ active: false
678
+ }
679
+ ];
680
+
681
+ // options with default values
682
+ const options = {
683
+ alwaysOpen: true,
684
+ activeClasses: 'bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white',
685
+ inactiveClasses: 'text-body',
686
+ onOpen: (item) => {
687
+ console.log('accordion item has been shown');
688
+ console.log(item);
689
+ },
690
+ onClose: (item) => {
691
+ console.log('accordion item has been hidden');
692
+ console.log(item);
693
+ },
694
+ onToggle: (item) => {
695
+ console.log('accordion item has been toggled');
696
+ console.log(item);
697
+ },
698
+ };
699
+
700
+ // instance options object
701
+ const instanceOptions = {
702
+ id: 'accordion-example',
703
+ override: true
704
+ };
705
+ {{< /code >}}
706
+
707
+ Create a new Accordion object using the options set above as the parameters.
708
+
709
+ {{< code lang="javascript" file="accordion.js" icon="file" >}}
710
+ import { Accordion } from 'flowbite';
711
+
712
+ /*
713
+ * accordionEl: HTML element (required)
714
+ * accordionItems: array of accordion item objects (required)
715
+ * options (optional)
716
+ * instanceOptions (optional)
717
+ */
718
+ const accordion = new Accordion(accordionElement, accordionItems, options, instanceOptions);
719
+ {{< /code >}}
720
+
721
+ Now you can access the object methods to programmatically open, close, and toggle the accordion items based on the unique identifier.
722
+
723
+ {{< code lang="javascript" file="accordion.js" icon="file" >}}
724
+ // open accordion item based on id
725
+ accordion.open('accordion-example-heading-2');
726
+
727
+ // close accordion item based on id
728
+ accordion.close('accordion-example-heading-2');
729
+
730
+ // toggle visibility of item based on id
731
+ accordion.toggle('accordion-example-heading-3');
732
+ {{< /code >}}
733
+
734
+ ### HTML Markup
735
+
736
+ Use the following HTML markup example for the JavaScript script above.
737
+
738
+ {{< code lang="html" file="accordion.html" icon="file" >}}
739
+ <div id="accordion-example">
740
+ <h2 id="accordion-example-heading-1">
741
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body border border-b-0 border-default rounded-t-xl focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-800 dark:border-gray-700 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800" aria-expanded="true" aria-controls="accordion-example-body-1">
742
+ <span>What is Flowbite?</span>
743
+ <svg data-accordion-icon class="w-6 h-6 rotate-180 shrink-0" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
744
+ </button>
745
+ </h2>
746
+ <div id="accordion-example-body-1" class="hidden" aria-labelledby="accordion-example-heading-1">
747
+ <div class="p-5 border border-b-0 border-default dark:border-gray-700 dark:bg-gray-900">
748
+ <p class="mb-2 text-body">Flowbite is an open-source library of interactive components built on top of Tailwind CSS including buttons, dropdowns, modals, navbars, and more.</p>
749
+ <p class="text-body">Check out this guide to learn how to <a href="/docs/getting-started/introduction/" class="text-fg-brand hover:underline">get started</a> and start developing websites even faster with components on top of Tailwind CSS.</p>
750
+ </div>
751
+ </div>
752
+ <h2 id="accordion-example-heading-2">
753
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body border border-b-0 border-default focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-800 dark:border-gray-700 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800" aria-expanded="false" aria-controls="accordion-example-body-2">
754
+ <span>Is there a Figma file available?</span>
755
+ <svg data-accordion-icon class="w-6 h-6 shrink-0" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
756
+ </button>
757
+ </h2>
758
+ <div id="accordion-example-body-2" class="hidden" aria-labelledby="accordion-example-heading-2">
759
+ <div class="p-5 border border-b-0 border-default dark:border-gray-700">
760
+ <p class="mb-2 text-body">Flowbite is first conceptualized and designed using the Figma software so everything you see in the library has a design equivalent in our Figma file.</p>
761
+ <p class="text-body">Check out the <a href="{{< param homepage >}}/figma/" class="text-fg-brand hover:underline">Figma design system</a> based on the utility classes from Tailwind CSS and components from Flowbite.</p>
762
+ </div>
763
+ </div>
764
+ <h2 id="accordion-example-heading-3">
765
+ <button type="button" class="flex items-center justify-between w-full p-5 font-medium rtl:text-right text-body border border-default focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-800 dark:border-gray-700 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800" aria-expanded="false" aria-controls="accordion-example-body-3">
766
+ <span>What are the differences between Flowbite and Tailwind UI?</span>
767
+ <svg data-accordion-icon class="w-6 h-6 shrink-0" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
768
+ </button>
769
+ </h2>
770
+ <div id="accordion-example-body-3" class="hidden" aria-labelledby="accordion-example-heading-3">
771
+ <div class="p-5 border border-t-0 border-default dark:border-gray-700">
772
+ <p class="mb-2 text-body">The main difference is that the core components from Flowbite are open source under the MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies on smaller and standalone components, whereas Tailwind UI offers sections of pages.</p>
773
+ <p class="mb-2 text-body">However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as there is no technical reason stopping you from using the best of two worlds.</p>
774
+ <p class="mb-2 text-body">Learn more about these technologies:</p>
775
+ <ul class="ps-5 text-body list-disc dark:text-gray-400">
776
+ <li><a href="{{< param homepage >}}/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
777
+ <li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
778
+ </ul>
779
+ </div>
780
+ </div>
781
+ </div>
782
+ {{< /code >}}
783
+
784
+ ### TypeScript
785
+
786
+ If you're using the <a href="{{< ref "getting-started/typescript" >}}">TypeScript configuration</a> from Flowbite then you can import the types for the Accordion object, parameters and its options.
787
+
788
+ Here's an example that applies the types from Flowbite to the code above:
789
+
790
+ {{< code lang="typescript" file="accordion.ts" icon="file" >}}
791
+ import { Accordion } from "flowbite";
792
+ import type { AccordionOptions, AccordionItem, AccordionInterface } from "flowbite";
793
+ import type { InstanceOptions } from 'flowbite';
794
+
795
+ const accordionEl = document.querySelector('#accordion-example');
796
+
797
+ // create an array of objects with the id, trigger element (eg. button), and the content element
798
+ const accordionItems: AccordionItem[] = [
799
+ {
800
+ id: 'accordion-example-heading-1',
801
+ triggerEl: document.querySelector('#accordion-example-heading-1'),
802
+ targetEl: document.querySelector('#accordion-example-body-1'),
803
+ active: true
804
+ },
805
+ {
806
+ id: 'accordion-example-heading-2',
807
+ triggerEl: document.querySelector('#accordion-example-heading-2'),
808
+ targetEl: document.querySelector('#accordion-example-body-2'),
809
+ active: false
810
+ },
811
+ {
812
+ id: 'accordion-example-heading-3',
813
+ triggerEl: document.querySelector('#accordion-example-heading-3'),
814
+ targetEl: document.querySelector('#accordion-example-body-3'),
815
+ active: false
816
+ }
817
+ ];
818
+
819
+ // options with default values
820
+ const options: AccordionOptions = {
821
+ alwaysOpen: true,
822
+ activeClasses: 'bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white',
823
+ inactiveClasses: 'text-body',
824
+ onOpen: (item) => {
825
+ console.log('accordion item has been shown');
826
+ console.log(item);
827
+ },
828
+ onClose: (item) => {
829
+ console.log('accordion item has been hidden');
830
+ console.log(item);
831
+ },
832
+ onToggle: (item) => {
833
+ console.log('accordion item has been toggled');
834
+ console.log(item);
835
+ },
836
+ };
837
+
838
+ // instance options object
839
+ const instanceOptions: InstanceOptions = {
840
+ id: 'accordion-example',
841
+ override: true
842
+ };
843
+
844
+ /*
845
+ * accordionEl: HTML element (required)
846
+ * accordionItems: array of accordion item objects (required)
847
+ * options (optional)
848
+ * instanceOptions (optional)
849
+ */
850
+ const accordion: AccordionInterface = new Accordion(accordionEl, accordionItems, options, instanceOptions);
851
+
852
+ // open accordion item based on id
853
+ accordion.open('accordion-example-heading-2');
854
+
855
+ // destroy accordion
856
+ accordion.destroy();
857
+
858
+ // re-initialize accordion
859
+ accordion.init();
860
+ {{< /code >}}