flowbite-mcp 1.1.3 → 1.1.5
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.
- package/README.md +49 -74
- package/build/index.js +20 -36
- package/data/components/accordion.md +39 -53
- package/data/components/alerts.md +27 -44
- package/data/components/avatar.md +20 -33
- package/data/components/badge.md +34 -47
- package/data/components/banner.md +10 -29
- package/data/components/bottom-navigation.md +16 -29
- package/data/components/breadcrumb.md +12 -25
- package/data/components/button-group.md +26 -39
- package/data/components/buttons.md +41 -67
- package/data/components/card.md +34 -47
- package/data/components/carousel.md +25 -39
- package/data/components/chat-bubble.md +36 -50
- package/data/components/clipboard.md +256 -252
- package/data/components/datepicker.md +56 -70
- package/data/components/device-mockups.md +16 -29
- package/data/components/drawer.md +42 -56
- package/data/components/dropdowns.md +66 -80
- package/data/components/footer.md +16 -29
- package/data/components/forms.md +32 -50
- package/data/components/gallery.md +16 -33
- package/data/components/indicators.md +18 -31
- package/data/components/jumbotron.md +12 -25
- package/data/components/kbd.md +14 -27
- package/data/components/list-group.md +14 -27
- package/data/components/mega-menu.md +10 -24
- package/data/components/modal.md +37 -51
- package/data/components/navbar.md +41 -55
- package/data/components/pagination.md +22 -35
- package/data/components/popover.md +36 -51
- package/data/components/progress.md +10 -23
- package/data/components/qr-code.md +41 -133
- package/data/components/rating.md +16 -29
- package/data/components/sidebar.md +15 -30
- package/data/components/skeleton.md +16 -29
- package/data/components/speed-dial.md +40 -55
- package/data/components/spinner.md +14 -27
- package/data/components/stepper.md +14 -27
- package/data/components/tables.md +45 -64
- package/data/components/tabs.md +30 -45
- package/data/components/timeline.md +10 -23
- package/data/components/toast.md +25 -39
- package/data/components/tooltips.md +24 -39
- package/data/components/typography.md +22 -35
- package/data/components/video.md +14 -27
- package/data/forms/checkbox.md +27 -43
- package/data/forms/file-input.md +12 -26
- package/data/forms/floating-label.md +12 -25
- package/data/forms/input-field.md +17 -32
- package/data/forms/number-input.md +83 -93
- package/data/forms/phone-input.md +42 -54
- package/data/forms/radio.md +23 -39
- package/data/forms/range.md +12 -26
- package/data/forms/search-input.md +14 -31
- package/data/forms/select.md +15 -30
- package/data/forms/textarea.md +8 -21
- package/data/forms/timepicker.md +30 -42
- package/data/forms/toggle.md +18 -31
- package/data/plugins/charts.md +542 -526
- package/data/plugins/datatables.md +285 -286
- package/data/plugins/wysiwyg.md +658 -650
- package/data/quickstart.md +24 -24
- package/data/typography/blockquote.md +24 -37
- package/data/typography/headings.md +30 -43
- package/data/typography/hr.md +10 -23
- package/data/typography/images.md +32 -45
- package/data/typography/links.md +16 -29
- package/data/typography/lists.md +22 -35
- package/data/typography/paragraphs.md +30 -43
- package/data/typography/text.md +42 -55
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,55 +38,12 @@ An [MCP server](https://flowbite.com/docs/getting-started/mcp/) that enables AI
|
|
|
38
38
|
The simplest way to use Flowbite MCP Server:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
# Run directly with npx (no installation needed)
|
|
42
41
|
npx flowbite-mcp
|
|
43
|
-
|
|
44
|
-
# Show help and options
|
|
45
|
-
npx flowbite-mcp --help
|
|
46
|
-
|
|
47
|
-
# Run in HTTP server mode for production
|
|
48
|
-
npx flowbite-mcp --mode http --port 3000
|
|
49
42
|
```
|
|
50
43
|
|
|
51
|
-
## Local Transport Modes
|
|
52
|
-
|
|
53
|
-
### Standard I/O (stdio)
|
|
54
|
-
|
|
55
|
-
The default mode for local development and CLI integrations:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
# Start in stdio mode (default)
|
|
59
|
-
node build/index.js
|
|
60
|
-
|
|
61
|
-
# Configure in MCP client (ie. Cursor, Windsurf, Claude)
|
|
62
|
-
{
|
|
63
|
-
"mcpServers": {
|
|
64
|
-
"flowbite": {
|
|
65
|
-
"command": "node",
|
|
66
|
-
"args": ["/path/to/flowbite-mcp/build/index.js"],
|
|
67
|
-
"env": {
|
|
68
|
-
"FIGMA_ACCESS_TOKEN": "YOUR_PERSONAL_FIGMA_ACCESS_TOKEN"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Learn how to get the [Figma personal access token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) to enable the Figma to code generation tool.
|
|
76
|
-
|
|
77
|
-
### HTTP server
|
|
78
|
-
|
|
79
|
-
HTTP-based transport for production and multi-client scenarios:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
node build/index.js --mode http --port 3000
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
This will make the MCP server available at 'http://localhost:3000/mcp'.
|
|
86
|
-
|
|
87
44
|
### Environment variables
|
|
88
45
|
|
|
89
|
-
Currently you only need the Figma personal access token
|
|
46
|
+
Currently you only need the [Figma personal access token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) if you want to enable the Figma to code generation tool.
|
|
90
47
|
|
|
91
48
|
```bash
|
|
92
49
|
// other options
|
|
@@ -95,27 +52,11 @@ Currently you only need the Figma personal access token if you want to enable th
|
|
|
95
52
|
}
|
|
96
53
|
```
|
|
97
54
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Configure the server behavior with these environment variables:
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
# Transport mode: stdio (default) or http
|
|
104
|
-
MCP_TRANSPORT_MODE=http
|
|
105
|
-
|
|
106
|
-
# Server port for HTTP mode
|
|
107
|
-
MCP_PORT=3000
|
|
108
|
-
|
|
109
|
-
# Host binding for HTTP mode
|
|
110
|
-
MCP_HOST=0.0.0.0
|
|
111
|
-
|
|
112
|
-
# CORS origins (comma-separated)
|
|
113
|
-
MCP_CORS_ORIGINS=http://localhost:3000,https://myapp.com
|
|
114
|
-
```
|
|
55
|
+
You set this variable in your MCP client configuration file.
|
|
115
56
|
|
|
116
57
|
## Integration examples
|
|
117
58
|
|
|
118
|
-
Use the following configuration examples to install the Flowbite MCP server in popular clients such as Cursor, Claude, Windsurf, and
|
|
59
|
+
Use the following configuration examples to install the Flowbite MCP server in popular clients such as Cursor, Claude, Windsurf, and others.
|
|
119
60
|
|
|
120
61
|
### Claude desktop
|
|
121
62
|
|
|
@@ -179,6 +120,41 @@ Update the `mcp_config.json` file and add the following configuration:
|
|
|
179
120
|
<img width="380" height="200" src="https://glama.ai/mcp/servers/@zoltanszogyenyi/flowbite-mcp/badge" />
|
|
180
121
|
</a>
|
|
181
122
|
|
|
123
|
+
## Local Transport Modes
|
|
124
|
+
|
|
125
|
+
### Standard I/O (stdio)
|
|
126
|
+
|
|
127
|
+
The default mode for local development and CLI integrations:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Start in stdio mode (default)
|
|
131
|
+
node build/index.js
|
|
132
|
+
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"flowbite": {
|
|
136
|
+
"command": "node",
|
|
137
|
+
"args": ["/path/to/flowbite-mcp/build/index.js"],
|
|
138
|
+
"env": {
|
|
139
|
+
"FIGMA_ACCESS_TOKEN": "YOUR_PERSONAL_FIGMA_ACCESS_TOKEN"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Learn how to get the [Figma personal access token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) to enable the Figma to code generation tool.
|
|
147
|
+
|
|
148
|
+
### HTTP server
|
|
149
|
+
|
|
150
|
+
HTTP-based transport for production and multi-client scenarios:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
node build/index.js --mode http --port 3000
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This will make the MCP server available at 'http://localhost:3000/mcp'.
|
|
157
|
+
|
|
182
158
|
### Local development
|
|
183
159
|
|
|
184
160
|
```bash
|
|
@@ -217,23 +193,22 @@ docker-compose up -d
|
|
|
217
193
|
curl http://localhost:3000/health
|
|
218
194
|
```
|
|
219
195
|
|
|
220
|
-
|
|
196
|
+
### Hosting variables
|
|
221
197
|
|
|
222
|
-
|
|
223
|
-
# Build TypeScript to JavaScript
|
|
224
|
-
npm run build
|
|
198
|
+
Configure the server behavior with these environment variables:
|
|
225
199
|
|
|
226
|
-
|
|
227
|
-
|
|
200
|
+
```bash
|
|
201
|
+
# Transport mode: stdio (default) or http
|
|
202
|
+
MCP_TRANSPORT_MODE=http
|
|
228
203
|
|
|
229
|
-
#
|
|
230
|
-
|
|
204
|
+
# Server port for HTTP mode
|
|
205
|
+
MCP_PORT=3000
|
|
231
206
|
|
|
232
|
-
#
|
|
233
|
-
|
|
207
|
+
# Host binding for HTTP mode
|
|
208
|
+
MCP_HOST=0.0.0.0
|
|
234
209
|
|
|
235
|
-
#
|
|
236
|
-
|
|
210
|
+
# CORS origins (comma-separated)
|
|
211
|
+
MCP_CORS_ORIGINS=http://localhost:3000,https://myapp.com
|
|
237
212
|
```
|
|
238
213
|
|
|
239
214
|
## Docker Configuration
|
package/build/index.js
CHANGED
|
@@ -15,17 +15,17 @@ const args = process.argv.slice(2);
|
|
|
15
15
|
if (args.includes('--version') || args.includes('-v')) {
|
|
16
16
|
try {
|
|
17
17
|
const packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
|
|
18
|
-
console.
|
|
18
|
+
console.error(`Flowbite MCP Server v${packageJson.version}`);
|
|
19
19
|
process.exit(0);
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
|
-
console.
|
|
22
|
+
console.error('Flowbite MCP Server (version unknown)');
|
|
23
23
|
process.exit(0);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
// Handle --help flag
|
|
27
27
|
if (args.includes('--help') || args.includes('-h')) {
|
|
28
|
-
console.
|
|
28
|
+
console.error(`
|
|
29
29
|
Flowbite MCP Server - AI-powered Flowbite component and theme generation
|
|
30
30
|
|
|
31
31
|
Usage:
|
|
@@ -57,7 +57,7 @@ const modeIndex = args.indexOf('--mode');
|
|
|
57
57
|
const portIndex = args.indexOf('--port');
|
|
58
58
|
const TRANSPORT_MODE = modeIndex !== -1 ? args[modeIndex + 1] : process.env.MCP_TRANSPORT_MODE || 'stdio';
|
|
59
59
|
const PORT = portIndex !== -1 ? parseInt(args[portIndex + 1]) : parseInt(process.env.MCP_PORT || '3000');
|
|
60
|
-
console.
|
|
60
|
+
console.error(`Initializing Flowbite MCP Server in ${TRANSPORT_MODE} mode${TRANSPORT_MODE === 'http' ? ` on port ${PORT}` : ''}`);
|
|
61
61
|
const COMPONENT_FILES = [
|
|
62
62
|
{
|
|
63
63
|
name: 'flowbite_accordion',
|
|
@@ -879,35 +879,19 @@ Look at the rendered image below and the node structure data to understand:
|
|
|
879
879
|
- Component patterns that match Flowbite components
|
|
880
880
|
|
|
881
881
|
### Step 2: Use Flowbite MCP Resources
|
|
882
|
-
Before writing code, fetch the relevant Flowbite component documentation using the MCP resources.
|
|
883
|
-
|
|
884
|
-
**Common Components to Check:**
|
|
885
|
-
- \`flowbite://components/buttons\` - For button styles
|
|
886
|
-
- \`flowbite://components/card\` - For card layouts
|
|
887
|
-
- \`flowbite://components/navbar\` - For navigation bars
|
|
888
|
-
- \`flowbite://components/modal\` - For modal dialogs
|
|
889
|
-
- \`flowbite://components/forms\` - For form layouts
|
|
890
|
-
- \`flowbite://forms/input-field\` - For input fields
|
|
891
|
-
- \`flowbite://components/avatar\` - For user avatars
|
|
892
|
-
- \`flowbite://components/badge\` - For badges/tags
|
|
893
|
-
- \`flowbite://components/tables\` - For data tables
|
|
894
|
-
- \`flowbite://components/tabs\` - For tab navigation
|
|
895
|
-
- \`flowbite://components/dropdowns\` - For dropdown menus
|
|
896
|
-
- \`flowbite://components/sidebar\` - For sidebar navigation
|
|
897
|
-
- \`flowbite://components/footer\` - For footer sections
|
|
898
|
-
- \`flowbite://typography/headings\` - For heading styles
|
|
899
|
-
- \`flowbite://typography/text\` - For text styles
|
|
882
|
+
Before writing code, fetch the relevant Flowbite component documentation using the MCP resources.
|
|
900
883
|
|
|
901
884
|
### Step 3: Write the Code
|
|
902
885
|
Generate clean, semantic HTML with Tailwind CSS classes following these guidelines:
|
|
903
886
|
|
|
904
887
|
1. **Use Flowbite Components**: Match the Figma design to Flowbite components whenever possible
|
|
905
|
-
2. **
|
|
906
|
-
3. **
|
|
907
|
-
4. **
|
|
908
|
-
5. **
|
|
909
|
-
6. **
|
|
910
|
-
7. **Match
|
|
888
|
+
2. **Flowbite variables** - Use Flowbite variable utility classes when possible (e.g. text-brand, rounded-base, etc.)
|
|
889
|
+
3. **Tailwind CSS Classes**: Use Tailwind utility classes for styling
|
|
890
|
+
4. **Responsive Design**: Include responsive breakpoints (sm:, md:, lg:, xl:)
|
|
891
|
+
5. **Semantic HTML**: Use proper HTML5 semantic elements
|
|
892
|
+
6. **Accessibility**: Include ARIA attributes and proper alt texts
|
|
893
|
+
7. **Match Colors**: Use Flowbite variables and secondly Tailwind color classes that best match the Figma design colors
|
|
894
|
+
8. **Match Spacing**: Use Tailwind spacing utilities (p-*, m-*, gap-*) to match the design
|
|
911
895
|
|
|
912
896
|
### Step 4: Output Format - IMPORTANT
|
|
913
897
|
|
|
@@ -1281,7 +1265,7 @@ Example usage:
|
|
|
1281
1265
|
// Start server based on transport mode
|
|
1282
1266
|
if (TRANSPORT_MODE === 'stdio') {
|
|
1283
1267
|
// Standard I/O mode for local development and CLI integrations
|
|
1284
|
-
console.
|
|
1268
|
+
console.error('Starting Flowbite MCP Server in stdio mode...');
|
|
1285
1269
|
const server = new McpServer({
|
|
1286
1270
|
name: "flowbite-mcp",
|
|
1287
1271
|
version: "1.0.0",
|
|
@@ -1297,19 +1281,19 @@ if (TRANSPORT_MODE === 'stdio') {
|
|
|
1297
1281
|
console.error('Failed to connect stdio transport:', error);
|
|
1298
1282
|
process.exit(1);
|
|
1299
1283
|
});
|
|
1300
|
-
console.
|
|
1301
|
-
console.
|
|
1284
|
+
console.error('Flowbite MCP Server running in stdio mode');
|
|
1285
|
+
console.error('Ready to accept requests via standard I/O');
|
|
1302
1286
|
}
|
|
1303
1287
|
else if (TRANSPORT_MODE === 'http') {
|
|
1304
1288
|
// HTTP Streamable mode for server/production deployments
|
|
1305
|
-
console.
|
|
1289
|
+
console.error(`Starting Flowbite MCP Server in HTTP mode on port ${PORT}...`);
|
|
1306
1290
|
ExpressHttpStreamableMcpServer({
|
|
1307
1291
|
name: "flowbite-mcp",
|
|
1308
1292
|
}, setupServer);
|
|
1309
|
-
console.
|
|
1310
|
-
console.
|
|
1311
|
-
console.
|
|
1312
|
-
console.
|
|
1293
|
+
console.error(`Flowbite MCP Server running in HTTP mode`);
|
|
1294
|
+
console.error(`Server listening on http://localhost:${PORT}`);
|
|
1295
|
+
console.error(`Health check: http://localhost:${PORT}/health`);
|
|
1296
|
+
console.error(`MCP endpoint: http://localhost:${PORT}/mcp`);
|
|
1313
1297
|
}
|
|
1314
1298
|
else {
|
|
1315
1299
|
console.error(`Invalid transport mode: ${TRANSPORT_MODE}`);
|
|
@@ -1,17 +1,3 @@
|
|
|
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
1
|
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
2
|
|
|
17
3
|
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.
|
|
@@ -27,7 +13,7 @@ Don't forget to set the `data-accordion-target="{selector}"` data attribute to t
|
|
|
27
13
|
|
|
28
14
|
Use the `data-accordion="collapse"` to collapse every other child element when expanding a single one.
|
|
29
15
|
|
|
30
|
-
|
|
16
|
+
```html
|
|
31
17
|
<div id="accordion-collapse" data-accordion="collapse" class="rounded-base border border-default overflow-hidden shadow-xs">
|
|
32
18
|
<h2 id="accordion-collapse-heading-1">
|
|
33
19
|
<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">
|
|
@@ -50,7 +36,7 @@ Use the `data-accordion="collapse"` to collapse every other child element when e
|
|
|
50
36
|
<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
37
|
<div class="p-4 md:p-5">
|
|
52
38
|
<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="
|
|
39
|
+
<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>
|
|
54
40
|
</div>
|
|
55
41
|
</div>
|
|
56
42
|
<h2 id="accordion-collapse-heading-3">
|
|
@@ -65,19 +51,19 @@ Use the `data-accordion="collapse"` to collapse every other child element when e
|
|
|
65
51
|
<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
52
|
<p class="mb-2 text-body">Learn more about these technologies:</p>
|
|
67
53
|
<ul class="ps-5 text-body list-disc">
|
|
68
|
-
<li><a href="
|
|
54
|
+
<li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
|
|
69
55
|
<li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
|
|
70
56
|
</ul>
|
|
71
57
|
</div>
|
|
72
58
|
</div>
|
|
73
59
|
</div>
|
|
74
|
-
|
|
60
|
+
```
|
|
75
61
|
|
|
76
62
|
## Separated cards
|
|
77
63
|
|
|
78
64
|
Use this example of an accordion with space delimitation between the accordion items.
|
|
79
65
|
|
|
80
|
-
|
|
66
|
+
```html
|
|
81
67
|
<div id="accordion-card" data-accordion="collapse">
|
|
82
68
|
<h2 id="accordion-card-heading-1">
|
|
83
69
|
<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">
|
|
@@ -100,7 +86,7 @@ Use this example of an accordion with space delimitation between the accordion i
|
|
|
100
86
|
<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
87
|
<div class="p-4 md:p-5">
|
|
102
88
|
<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="
|
|
89
|
+
<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>
|
|
104
90
|
</div>
|
|
105
91
|
</div>
|
|
106
92
|
<h2 id="accordion-card-heading-3" class="mt-4">
|
|
@@ -115,19 +101,19 @@ Use this example of an accordion with space delimitation between the accordion i
|
|
|
115
101
|
<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
102
|
<p class="mb-2 text-body">Learn more about these technologies:</p>
|
|
117
103
|
<ul class="ps-5 text-body list-disc">
|
|
118
|
-
<li><a href="
|
|
104
|
+
<li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
|
|
119
105
|
<li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
|
|
120
106
|
</ul>
|
|
121
107
|
</div>
|
|
122
108
|
</div>
|
|
123
109
|
</div>
|
|
124
|
-
|
|
110
|
+
```
|
|
125
111
|
|
|
126
112
|
## Always open
|
|
127
113
|
|
|
128
114
|
Use the `data-accordion="open"` option to keep previously opened accordion elements unchanged.
|
|
129
115
|
|
|
130
|
-
|
|
116
|
+
```html
|
|
131
117
|
<div id="accordion-open" data-accordion="open" class="rounded-base border border-default overflow-hidden shadow-xs">
|
|
132
118
|
<h2 id="accordion-open-heading-1">
|
|
133
119
|
<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">
|
|
@@ -150,7 +136,7 @@ Use the `data-accordion="open"` option to keep previously opened accordion eleme
|
|
|
150
136
|
<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
137
|
<div class="p-4 md:p-5">
|
|
152
138
|
<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="
|
|
139
|
+
<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>
|
|
154
140
|
</div>
|
|
155
141
|
</div>
|
|
156
142
|
<h2 id="accordion-open-heading-3">
|
|
@@ -165,13 +151,13 @@ Use the `data-accordion="open"` option to keep previously opened accordion eleme
|
|
|
165
151
|
<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
152
|
<p class="mb-2 text-body">Learn more about these technologies:</p>
|
|
167
153
|
<ul class="ps-5 text-body list-disc">
|
|
168
|
-
<li><a href="
|
|
154
|
+
<li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
|
|
169
155
|
<li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
|
|
170
156
|
</ul>
|
|
171
157
|
</div>
|
|
172
158
|
</div>
|
|
173
159
|
</div>
|
|
174
|
-
|
|
160
|
+
```
|
|
175
161
|
|
|
176
162
|
## Color options
|
|
177
163
|
|
|
@@ -179,7 +165,7 @@ Use the `data-active-classes` and `data-inactive-classes` to set the active and
|
|
|
179
165
|
|
|
180
166
|
Here's an example where we apply the blue colors instead of gray:
|
|
181
167
|
|
|
182
|
-
|
|
168
|
+
```html
|
|
183
169
|
<div id="accordion-color" data-accordion="collapse" class="rounded-base border border-default overflow-hidden shadow-xs">
|
|
184
170
|
<h2 id="accordion-color-heading-1">
|
|
185
171
|
<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">
|
|
@@ -202,7 +188,7 @@ Here's an example where we apply the blue colors instead of gray:
|
|
|
202
188
|
<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
189
|
<div class="p-4 md:p-5">
|
|
204
190
|
<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="
|
|
191
|
+
<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>
|
|
206
192
|
</div>
|
|
207
193
|
</div>
|
|
208
194
|
<h2 id="accordion-color-heading-3">
|
|
@@ -217,19 +203,19 @@ Here's an example where we apply the blue colors instead of gray:
|
|
|
217
203
|
<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
204
|
<p class="mb-2 text-body">Learn more about these technologies:</p>
|
|
219
205
|
<ul class="ps-5 text-body list-disc">
|
|
220
|
-
<li><a href="
|
|
206
|
+
<li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
|
|
221
207
|
<li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
|
|
222
208
|
</ul>
|
|
223
209
|
</div>
|
|
224
210
|
</div>
|
|
225
211
|
</div>
|
|
226
|
-
|
|
212
|
+
```
|
|
227
213
|
|
|
228
214
|
## Flush accordion
|
|
229
215
|
|
|
230
216
|
Use this example to remove the background color and rounded borders from the accordion component.
|
|
231
217
|
|
|
232
|
-
|
|
218
|
+
```html
|
|
233
219
|
<div id="accordion-flush" data-accordion="collapse" data-active-classes="bg-neutral-primary text-heading" data-inactive-classes="text-body">
|
|
234
220
|
<h2 id="accordion-flush-heading-1">
|
|
235
221
|
<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">
|
|
@@ -252,7 +238,7 @@ Use this example to remove the background color and rounded borders from the acc
|
|
|
252
238
|
<div id="accordion-flush-body-2" class="hidden" aria-labelledby="accordion-flush-heading-2">
|
|
253
239
|
<div class="py-5 border-b border-default text-body">
|
|
254
240
|
<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="
|
|
241
|
+
<p>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>
|
|
256
242
|
</div>
|
|
257
243
|
</div>
|
|
258
244
|
<h2 id="accordion-flush-heading-3">
|
|
@@ -267,19 +253,19 @@ Use this example to remove the background color and rounded borders from the acc
|
|
|
267
253
|
<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
254
|
<p class="mb-2">Learn more about these technologies:</p>
|
|
269
255
|
<ul class="ps-5 list-disc">
|
|
270
|
-
<li><a href="
|
|
256
|
+
<li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
|
|
271
257
|
<li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
|
|
272
258
|
</ul>
|
|
273
259
|
</div>
|
|
274
260
|
</div>
|
|
275
261
|
</div>
|
|
276
|
-
|
|
262
|
+
```
|
|
277
263
|
|
|
278
264
|
## Arrow style
|
|
279
265
|
|
|
280
266
|
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
267
|
|
|
282
|
-
|
|
268
|
+
```html
|
|
283
269
|
<div id="accordion-arrow" data-accordion="collapse" data-active-classes="bg-neutral-primary text-heading" data-inactive-classes="text-body">
|
|
284
270
|
<h2 id="accordion-arrow-heading-1">
|
|
285
271
|
<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">
|
|
@@ -303,7 +289,7 @@ Use the `data-accordion-icon` data attribute to optionally set an element to rot
|
|
|
303
289
|
<div id="accordion-arrow-body-2" class="hidden" aria-labelledby="accordion-arrow-heading-2">
|
|
304
290
|
<div class="py-5 border-b border-default text-body">
|
|
305
291
|
<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="
|
|
292
|
+
<p>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>
|
|
307
293
|
</div>
|
|
308
294
|
</div>
|
|
309
295
|
<h2 id="accordion-arrow-heading-3">
|
|
@@ -318,13 +304,13 @@ Use the `data-accordion-icon` data attribute to optionally set an element to rot
|
|
|
318
304
|
<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
305
|
<p class="mb-2">Learn more about these technologies:</p>
|
|
320
306
|
<ul class="ps-5 list-disc">
|
|
321
|
-
<li><a href="
|
|
307
|
+
<li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
|
|
322
308
|
<li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
|
|
323
309
|
</ul>
|
|
324
310
|
</div>
|
|
325
311
|
</div>
|
|
326
312
|
</div>
|
|
327
|
-
|
|
313
|
+
```
|
|
328
314
|
|
|
329
315
|
## Nesting accordions
|
|
330
316
|
|
|
@@ -332,7 +318,7 @@ Accordions can be nested. All of the mentioned options are supported.
|
|
|
332
318
|
|
|
333
319
|
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
320
|
|
|
335
|
-
|
|
321
|
+
```html
|
|
336
322
|
|
|
337
323
|
<div id="accordion-collapse-2" data-accordion="collapse" class="rounded-base border border-default overflow-hidden shadow-xs">
|
|
338
324
|
<h2 id="accordion-collapse-heading-6">
|
|
@@ -408,7 +394,7 @@ To enable nested accordions you need to wrap the nested accordion in an element
|
|
|
408
394
|
</div>
|
|
409
395
|
</div>
|
|
410
396
|
</div>
|
|
411
|
-
|
|
397
|
+
```
|
|
412
398
|
|
|
413
399
|
## JavaScript behaviour
|
|
414
400
|
|
|
@@ -653,7 +639,7 @@ To get started you need to create an array of accordion item objects including a
|
|
|
653
639
|
|
|
654
640
|
Additionally, you can also set some options to change the default behaviour of the accordion, customize the styles, and set callback functions.
|
|
655
641
|
|
|
656
|
-
|
|
642
|
+
```javascript
|
|
657
643
|
const accordionElement = document.getElementById('accordion-example');
|
|
658
644
|
|
|
659
645
|
// create an array of objects with the id, trigger element (eg. button), and the content element
|
|
@@ -702,11 +688,11 @@ const instanceOptions = {
|
|
|
702
688
|
id: 'accordion-example',
|
|
703
689
|
override: true
|
|
704
690
|
};
|
|
705
|
-
|
|
691
|
+
```
|
|
706
692
|
|
|
707
693
|
Create a new Accordion object using the options set above as the parameters.
|
|
708
694
|
|
|
709
|
-
|
|
695
|
+
```javascript
|
|
710
696
|
import { Accordion } from 'flowbite';
|
|
711
697
|
|
|
712
698
|
/*
|
|
@@ -716,11 +702,11 @@ import { Accordion } from 'flowbite';
|
|
|
716
702
|
* instanceOptions (optional)
|
|
717
703
|
*/
|
|
718
704
|
const accordion = new Accordion(accordionElement, accordionItems, options, instanceOptions);
|
|
719
|
-
|
|
705
|
+
```
|
|
720
706
|
|
|
721
707
|
Now you can access the object methods to programmatically open, close, and toggle the accordion items based on the unique identifier.
|
|
722
708
|
|
|
723
|
-
|
|
709
|
+
```javascript
|
|
724
710
|
// open accordion item based on id
|
|
725
711
|
accordion.open('accordion-example-heading-2');
|
|
726
712
|
|
|
@@ -729,13 +715,13 @@ accordion.close('accordion-example-heading-2');
|
|
|
729
715
|
|
|
730
716
|
// toggle visibility of item based on id
|
|
731
717
|
accordion.toggle('accordion-example-heading-3');
|
|
732
|
-
|
|
718
|
+
```
|
|
733
719
|
|
|
734
720
|
### HTML Markup
|
|
735
721
|
|
|
736
722
|
Use the following HTML markup example for the JavaScript script above.
|
|
737
723
|
|
|
738
|
-
|
|
724
|
+
```html
|
|
739
725
|
<div id="accordion-example">
|
|
740
726
|
<h2 id="accordion-example-heading-1">
|
|
741
727
|
<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">
|
|
@@ -758,7 +744,7 @@ Use the following HTML markup example for the JavaScript script above.
|
|
|
758
744
|
<div id="accordion-example-body-2" class="hidden" aria-labelledby="accordion-example-heading-2">
|
|
759
745
|
<div class="p-5 border border-b-0 border-default dark:border-gray-700">
|
|
760
746
|
<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="
|
|
747
|
+
<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>
|
|
762
748
|
</div>
|
|
763
749
|
</div>
|
|
764
750
|
<h2 id="accordion-example-heading-3">
|
|
@@ -773,21 +759,21 @@ Use the following HTML markup example for the JavaScript script above.
|
|
|
773
759
|
<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
760
|
<p class="mb-2 text-body">Learn more about these technologies:</p>
|
|
775
761
|
<ul class="ps-5 text-body list-disc dark:text-gray-400">
|
|
776
|
-
<li><a href="
|
|
762
|
+
<li><a href="https://flowbite.com/pro/" class="text-fg-brand hover:underline">Flowbite Pro</a></li>
|
|
777
763
|
<li><a href="https://tailwindui.com/" rel="nofollow" class="text-fg-brand hover:underline">Tailwind UI</a></li>
|
|
778
764
|
</ul>
|
|
779
765
|
</div>
|
|
780
766
|
</div>
|
|
781
767
|
</div>
|
|
782
|
-
|
|
768
|
+
```
|
|
783
769
|
|
|
784
770
|
### TypeScript
|
|
785
771
|
|
|
786
|
-
If you're using the
|
|
772
|
+
If you're using the TypeScript configuration from Flowbite then you can import the types for the Accordion object, parameters and its options.
|
|
787
773
|
|
|
788
774
|
Here's an example that applies the types from Flowbite to the code above:
|
|
789
775
|
|
|
790
|
-
|
|
776
|
+
```typescript
|
|
791
777
|
import { Accordion } from "flowbite";
|
|
792
778
|
import type { AccordionOptions, AccordionItem, AccordionInterface } from "flowbite";
|
|
793
779
|
import type { InstanceOptions } from 'flowbite';
|
|
@@ -857,4 +843,4 @@ accordion.destroy();
|
|
|
857
843
|
|
|
858
844
|
// re-initialize accordion
|
|
859
845
|
accordion.init();
|
|
860
|
-
|
|
846
|
+
```
|