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.
Files changed (72) hide show
  1. package/README.md +49 -74
  2. package/build/index.js +20 -36
  3. package/data/components/accordion.md +39 -53
  4. package/data/components/alerts.md +27 -44
  5. package/data/components/avatar.md +20 -33
  6. package/data/components/badge.md +34 -47
  7. package/data/components/banner.md +10 -29
  8. package/data/components/bottom-navigation.md +16 -29
  9. package/data/components/breadcrumb.md +12 -25
  10. package/data/components/button-group.md +26 -39
  11. package/data/components/buttons.md +41 -67
  12. package/data/components/card.md +34 -47
  13. package/data/components/carousel.md +25 -39
  14. package/data/components/chat-bubble.md +36 -50
  15. package/data/components/clipboard.md +256 -252
  16. package/data/components/datepicker.md +56 -70
  17. package/data/components/device-mockups.md +16 -29
  18. package/data/components/drawer.md +42 -56
  19. package/data/components/dropdowns.md +66 -80
  20. package/data/components/footer.md +16 -29
  21. package/data/components/forms.md +32 -50
  22. package/data/components/gallery.md +16 -33
  23. package/data/components/indicators.md +18 -31
  24. package/data/components/jumbotron.md +12 -25
  25. package/data/components/kbd.md +14 -27
  26. package/data/components/list-group.md +14 -27
  27. package/data/components/mega-menu.md +10 -24
  28. package/data/components/modal.md +37 -51
  29. package/data/components/navbar.md +41 -55
  30. package/data/components/pagination.md +22 -35
  31. package/data/components/popover.md +36 -51
  32. package/data/components/progress.md +10 -23
  33. package/data/components/qr-code.md +41 -133
  34. package/data/components/rating.md +16 -29
  35. package/data/components/sidebar.md +15 -30
  36. package/data/components/skeleton.md +16 -29
  37. package/data/components/speed-dial.md +40 -55
  38. package/data/components/spinner.md +14 -27
  39. package/data/components/stepper.md +14 -27
  40. package/data/components/tables.md +45 -64
  41. package/data/components/tabs.md +30 -45
  42. package/data/components/timeline.md +10 -23
  43. package/data/components/toast.md +25 -39
  44. package/data/components/tooltips.md +24 -39
  45. package/data/components/typography.md +22 -35
  46. package/data/components/video.md +14 -27
  47. package/data/forms/checkbox.md +27 -43
  48. package/data/forms/file-input.md +12 -26
  49. package/data/forms/floating-label.md +12 -25
  50. package/data/forms/input-field.md +17 -32
  51. package/data/forms/number-input.md +83 -93
  52. package/data/forms/phone-input.md +42 -54
  53. package/data/forms/radio.md +23 -39
  54. package/data/forms/range.md +12 -26
  55. package/data/forms/search-input.md +14 -31
  56. package/data/forms/select.md +15 -30
  57. package/data/forms/textarea.md +8 -21
  58. package/data/forms/timepicker.md +30 -42
  59. package/data/forms/toggle.md +18 -31
  60. package/data/plugins/charts.md +542 -526
  61. package/data/plugins/datatables.md +285 -286
  62. package/data/plugins/wysiwyg.md +658 -650
  63. package/data/quickstart.md +24 -24
  64. package/data/typography/blockquote.md +24 -37
  65. package/data/typography/headings.md +30 -43
  66. package/data/typography/hr.md +10 -23
  67. package/data/typography/images.md +32 -45
  68. package/data/typography/links.md +16 -29
  69. package/data/typography/lists.md +22 -35
  70. package/data/typography/paragraphs.md +30 -43
  71. package/data/typography/text.md +42 -55
  72. package/package.json +1 -1
@@ -1,17 +1,3 @@
1
- ---
2
- layout: docs
3
- title: Tailwind CSS Copy to Clipboard - Flowbite
4
- description: Use the clipboard component to copy text, data or lines of code to the clipboard with a single click based on various styles and examples coded with Tailwind CSS and Flowbite
5
- group: components
6
- toc: true
7
- requires_js: true
8
-
9
- previous: Chat Bubble
10
- previousLink: components/chat-bubble/
11
- next: Datepicker
12
- nextLink: components/datepicker/
13
- ---
14
-
15
1
  The copy to clipboard component allows you to copy text, lines of code, contact details or any other data to the clipboard with a single click on a trigger element such as a button. This component can be used to copy text from an input field, textarea, code block or even address fields in a form element.
16
2
 
17
3
  Use cases for websites can be found in the examples below and they include copying code installation commands, API keys, URLs, addresses, contact details, sharing course URLs inside a modal and more.
@@ -24,7 +10,23 @@ Make sure that you add the `data-copy-to-clipboard-target="elementID"` data attr
24
10
 
25
11
  Use this example to copy the content of an input text field by clicking on a button and update the button text by applying the JavaScript code from the tab below based on the `updateOnCopyCallback()` function callback from the Flowbite JS API.
26
12
 
27
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="280" javascript=`
13
+ ```html
14
+ <div class="grid grid-cols-8 gap-2 w-full max-w-[23rem]">
15
+ <label for="npm-install" class="sr-only">Label</label>
16
+ <input id="npm-install" type="text" class="col-span-6 bg-neutral-secondary-medium border border-default-medium text-body text-sm rounded-base focus:ring-brand focus:border-brand block w-full px-3 py-2.5 shadow-xs placeholder:text-body" value="npm install flowbite" disabled readonly>
17
+ <button data-copy-to-clipboard-target="npm-install" class="col-span-2 col-span-2 text-white bg-brand box-border border border-transparent hover:bg-brand-strong focus:ring-4 focus:ring-brand-medium shadow-xs font-medium leading-5 rounded-base text-sm py-2.5 focus:outline-none sm:w-auto">
18
+ <span id="default-message">Copy</span>
19
+ <span id="success-message" class="hidden">
20
+ <div class="inline-flex items-center">
21
+ <svg class="w-3 h-3 me-1" 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 11.917 9.724 16.5 19 7.5"/></svg>
22
+ Copied!
23
+ </div>
24
+ </span>
25
+ </button>
26
+ </div>
27
+ ```
28
+
29
+ ```javascript
28
30
  window.addEventListener('load', function() {
29
31
  const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'npm-install');
30
32
  const $defaultMessage = document.getElementById('default-message');
@@ -41,21 +43,7 @@ window.addEventListener('load', function() {
41
43
  }, 2000);
42
44
  });
43
45
  })
44
- ` >}}
45
- <div class="grid grid-cols-8 gap-2 w-full max-w-[23rem]">
46
- <label for="npm-install" class="sr-only">Label</label>
47
- <input id="npm-install" type="text" class="col-span-6 bg-neutral-secondary-medium border border-default-medium text-body text-sm rounded-base focus:ring-brand focus:border-brand block w-full px-3 py-2.5 shadow-xs placeholder:text-body" value="npm install flowbite" disabled readonly>
48
- <button data-copy-to-clipboard-target="npm-install" class="col-span-2 col-span-2 text-white bg-brand box-border border border-transparent hover:bg-brand-strong focus:ring-4 focus:ring-brand-medium shadow-xs font-medium leading-5 rounded-base text-sm py-2.5 focus:outline-none sm:w-auto">
49
- <span id="default-message">Copy</span>
50
- <span id="success-message" class="hidden">
51
- <div class="inline-flex items-center">
52
- <svg class="w-3 h-3 me-1" 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 11.917 9.724 16.5 19 7.5"/></svg>
53
- Copied!
54
- </div>
55
- </span>
56
- </button>
57
- </div>
58
- {{< /example >}}
46
+ ```
59
47
 
60
48
  ## Input with copy button
61
49
 
@@ -63,7 +51,29 @@ This example can be used to copy the content of an input field by clicking on a
63
51
 
64
52
  If you also want to update the text inside the tooltip and the icon, then you need to apply the JavaScript code based on the `updateOnCopyCallback()` function callback from the Flowbite JS API.
65
53
 
66
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="280" javascript=`
54
+ ```html
55
+ <div class="w-full max-w-[16rem]">
56
+ <div class="relative">
57
+ <label for="npm-install-copy-button" class="sr-only">Label</label>
58
+ <input id="npm-install-copy-button" type="text" class="col-span-6 bg-neutral-secondary-medium border border-default-medium text-body text-sm rounded-base focus:ring-brand focus:border-brand block w-full px-3 py-2.5 shadow-xs placeholder:text-body" value="npm install flowbite" disabled readonly>
59
+ <button data-copy-to-clipboard-target="npm-install-copy-button" data-tooltip-target="tooltip-copy-npm-install-copy-button" class="absolute end-2 top-1/2 -translate-y-1/2 text-body hover:bg-neutral-quaternary rounded p-1.5 inline-flex items-center justify-center">
60
+ <span id="default-icon">
61
+ <svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3m0 3h6m-6 5h6m-6 4h6M10 3v4h4V3h-4Z"/></svg>
62
+ </span>
63
+ <span id="success-icon" class="hidden">
64
+ <svg class="w-4 h-4 text-fg-brand" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3m0 3h6m-6 7 2 2 4-4m-5-9v4h4V3h-4Z"/></svg>
65
+ </span>
66
+ </button>
67
+ <div id="tooltip-copy-npm-install-copy-button" role="tooltip" class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-dark rounded-base shadow-xs opacity-0 tooltip">
68
+ <span id="default-tooltip-message">Copy to clipboard</span>
69
+ <span id="success-tooltip-message" class="hidden">Copied!</span>
70
+ <div class="tooltip-arrow" data-popper-arrow></div>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ ```
75
+
76
+ ```javascript
67
77
  window.addEventListener('load', function () {
68
78
  const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'npm-install-copy-button');
69
79
  const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-copy-npm-install-copy-button');
@@ -99,59 +109,13 @@ window.addEventListener('load', function () {
99
109
  tooltip.hide();
100
110
  }
101
111
  })
102
- ` >}}
103
- <div class="w-full max-w-[16rem]">
104
- <div class="relative">
105
- <label for="npm-install-copy-button" class="sr-only">Label</label>
106
- <input id="npm-install-copy-button" type="text" class="col-span-6 bg-neutral-secondary-medium border border-default-medium text-body text-sm rounded-base focus:ring-brand focus:border-brand block w-full px-3 py-2.5 shadow-xs placeholder:text-body" value="npm install flowbite" disabled readonly>
107
- <button data-copy-to-clipboard-target="npm-install-copy-button" data-tooltip-target="tooltip-copy-npm-install-copy-button" class="absolute end-2 top-1/2 -translate-y-1/2 text-body hover:bg-neutral-quaternary rounded p-1.5 inline-flex items-center justify-center">
108
- <span id="default-icon">
109
- <svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3m0 3h6m-6 5h6m-6 4h6M10 3v4h4V3h-4Z"/></svg>
110
- </span>
111
- <span id="success-icon" class="hidden">
112
- <svg class="w-4 h-4 text-fg-brand" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3m0 3h6m-6 7 2 2 4-4m-5-9v4h4V3h-4Z"/></svg>
113
- </span>
114
- </button>
115
- <div id="tooltip-copy-npm-install-copy-button" role="tooltip" class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-dark rounded-base shadow-xs opacity-0 tooltip">
116
- <span id="default-tooltip-message">Copy to clipboard</span>
117
- <span id="success-tooltip-message" class="hidden">Copied!</span>
118
- <div class="tooltip-arrow" data-popper-arrow></div>
119
- </div>
120
- </div>
121
- </div>
122
- {{< /example >}}
112
+ ```
123
113
 
124
114
  ## Copy button with text
125
115
 
126
116
  Use this example to show a copy button inside the input field with a text label and icon that updates to a success state when the text has been copied. Make sure that you also apply the custom JavaScript code below to enable the success and default message states.
127
117
 
128
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="280" javascript=`
129
- window.addEventListener('load', function () {
130
- const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'npm-install-copy-text');
131
-
132
- const $defaultMessage = document.getElementById('default-message');
133
- const $successMessage = document.getElementById('success-message');
134
-
135
- clipboard.updateOnCopyCallback((clipboard) => {
136
- showSuccess();
137
-
138
- // reset to default state
139
- setTimeout(() => {
140
- resetToDefault();
141
- }, 2000);
142
- })
143
-
144
- const showSuccess = () => {
145
- $defaultMessage.classList.add('hidden');
146
- $successMessage.classList.remove('hidden');
147
- }
148
-
149
- const resetToDefault = () => {
150
- $defaultMessage.classList.remove('hidden');
151
- $successMessage.classList.add('hidden');
152
- }
153
- })
154
- ` >}}
118
+ ```html
155
119
  <div class="w-full max-w-[18rem]">
156
120
  <div class="relative">
157
121
  <label for="npm-install-copy-text" class="sr-only">Label</label>
@@ -172,22 +136,14 @@ window.addEventListener('load', function () {
172
136
  </button>
173
137
  </div>
174
138
  </div>
175
- {{< /example >}}
176
-
177
- ## Input group with copy
178
-
179
- This example can be used to show a copy to clipboard button inside an input group which has a label positioned inside the input field. The icon inside the button will switch to a success state if you also apply the custom JavaScript code below.
139
+ ```
180
140
 
181
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="280" javascript=`
141
+ ```javascript
182
142
  window.addEventListener('load', function () {
183
- const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'website-url');
184
- const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-website-url');
185
-
186
- const $defaultIcon = document.getElementById('default-icon');
187
- const $successIcon = document.getElementById('success-icon');
143
+ const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'npm-install-copy-text');
188
144
 
189
- const $defaultTooltipMessage = document.getElementById('default-tooltip-message');
190
- const $successTooltipMessage = document.getElementById('success-tooltip-message');
145
+ const $defaultMessage = document.getElementById('default-message');
146
+ const $successMessage = document.getElementById('success-message');
191
147
 
192
148
  clipboard.updateOnCopyCallback((clipboard) => {
193
149
  showSuccess();
@@ -199,22 +155,22 @@ window.addEventListener('load', function () {
199
155
  })
200
156
 
201
157
  const showSuccess = () => {
202
- $defaultIcon.classList.add('hidden');
203
- $successIcon.classList.remove('hidden');
204
- $defaultTooltipMessage.classList.add('hidden');
205
- $successTooltipMessage.classList.remove('hidden');
206
- tooltip.show();
158
+ $defaultMessage.classList.add('hidden');
159
+ $successMessage.classList.remove('hidden');
207
160
  }
208
161
 
209
162
  const resetToDefault = () => {
210
- $defaultIcon.classList.remove('hidden');
211
- $successIcon.classList.add('hidden');
212
- $defaultTooltipMessage.classList.remove('hidden');
213
- $successTooltipMessage.classList.add('hidden');
214
- tooltip.hide();
163
+ $defaultMessage.classList.remove('hidden');
164
+ $successMessage.classList.add('hidden');
215
165
  }
216
166
  })
217
- ` >}}
167
+ ```
168
+
169
+ ## Input group with copy
170
+
171
+ This example can be used to show a copy to clipboard button inside an input group which has a label positioned inside the input field. The icon inside the button will switch to a success state if you also apply the custom JavaScript code below.
172
+
173
+ ```html
218
174
  <div class="w-full max-w-sm">
219
175
  <label for="website-url" class="block mb-2.5 text-sm font-medium text-heading">Verify your website:</label>
220
176
  <div class="flex items-stretch rounded-base shadow-xs">
@@ -243,16 +199,12 @@ window.addEventListener('load', function () {
243
199
  </div>
244
200
  <p id="helper-text-explanation" class="mt-2.5 text-sm text-body">Security certificate is required for approval</p>
245
201
  </div>
246
- {{< /example >}}
202
+ ```
247
203
 
248
- ## URL shortener input group
249
-
250
- Use this example to copy a shortened URL to the clipboard by clicking on a button with an icon positioned inside the input field and also show a tooltip with a message when the text has been copied.
251
-
252
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="280" javascript=`
253
- window.addEventListener('load', function() {
254
- const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'url-shortener');
255
- const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-url-shortener');
204
+ ```javascript
205
+ window.addEventListener('load', function () {
206
+ const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'website-url');
207
+ const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-website-url');
256
208
 
257
209
  const $defaultIcon = document.getElementById('default-icon');
258
210
  const $successIcon = document.getElementById('success-icon');
@@ -285,7 +237,13 @@ window.addEventListener('load', function() {
285
237
  tooltip.hide();
286
238
  }
287
239
  })
288
- ` >}}
240
+ ```
241
+
242
+ ## URL shortener input group
243
+
244
+ Use this example to copy a shortened URL to the clipboard by clicking on a button with an icon positioned inside the input field and also show a tooltip with a message when the text has been copied.
245
+
246
+ ```html
289
247
  <div class="w-full max-w-sm">
290
248
  <label for="url-shortener" class="block mb-2.5 text-sm font-medium text-heading">Shorten URL:</label>
291
249
  <div class="flex items-stretch shadow-xs rounded-base">
@@ -315,22 +273,18 @@ window.addEventListener('load', function() {
315
273
  </div>
316
274
  <p id="helper-text-explanation" class="mt-2.5 text-sm text-body">Make sure that your URL is valid</p>
317
275
  </div>
318
- {{< /example >}}
276
+ ```
319
277
 
320
- ## Copy source code block
321
-
322
- This example can be used to copy and paste code inside a `<pre>` and `<code>` block by clicking on a button with an icon position inside the block and also show a tooltip with a message when the text has been copied.
323
-
324
- You need to add an extra `data-copy-to-clipboard-content-type="innerHTML"` data attribute to the trigger element (ie. the button) to specify that the content that is to be copied is from the `innerHTML` of the target element (ie. the code block).
325
-
326
- You also need to add the `data-copy-to-clipboard-html-entities="true"` option to the trigger element so that the copied text will be decoded from HTML entities to plain text that will work inside your code editor.
278
+ ```javascript
279
+ window.addEventListener('load', function() {
280
+ const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'url-shortener');
281
+ const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-url-shortener');
327
282
 
328
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="480" javascript=`
329
- window.addEventListener('load', function () {
330
- const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'code-block');
283
+ const $defaultIcon = document.getElementById('default-icon');
284
+ const $successIcon = document.getElementById('success-icon');
331
285
 
332
- const $defaultMessage = document.getElementById('default-message');
333
- const $successMessage = document.getElementById('success-message');
286
+ const $defaultTooltipMessage = document.getElementById('default-tooltip-message');
287
+ const $successTooltipMessage = document.getElementById('success-tooltip-message');
334
288
 
335
289
  clipboard.updateOnCopyCallback((clipboard) => {
336
290
  showSuccess();
@@ -342,16 +296,32 @@ window.addEventListener('load', function () {
342
296
  })
343
297
 
344
298
  const showSuccess = () => {
345
- $defaultMessage.classList.add('hidden');
346
- $successMessage.classList.remove('hidden');
299
+ $defaultIcon.classList.add('hidden');
300
+ $successIcon.classList.remove('hidden');
301
+ $defaultTooltipMessage.classList.add('hidden');
302
+ $successTooltipMessage.classList.remove('hidden');
303
+ tooltip.show();
347
304
  }
348
305
 
349
306
  const resetToDefault = () => {
350
- $defaultMessage.classList.remove('hidden');
351
- $successMessage.classList.add('hidden');
307
+ $defaultIcon.classList.remove('hidden');
308
+ $successIcon.classList.add('hidden');
309
+ $defaultTooltipMessage.classList.remove('hidden');
310
+ $successTooltipMessage.classList.add('hidden');
311
+ tooltip.hide();
352
312
  }
353
313
  })
354
- ` >}}
314
+ ```
315
+
316
+ ## Copy source code block
317
+
318
+ This example can be used to copy and paste code inside a `<pre>` and `<code>` block by clicking on a button with an icon position inside the block and also show a tooltip with a message when the text has been copied.
319
+
320
+ You need to add an extra `data-copy-to-clipboard-content-type="innerHTML"` data attribute to the trigger element (ie. the button) to specify that the content that is to be copied is from the `innerHTML` of the target element (ie. the code block).
321
+
322
+ You also need to add the `data-copy-to-clipboard-html-entities="true"` option to the trigger element so that the copied text will be decoded from HTML entities to plain text that will work inside your code editor.
323
+
324
+ ```html
355
325
  <div class="w-full max-w-lg">
356
326
  <div class="mb-2 flex justify-between items-center">
357
327
  <p class="block mb-2.5 text-sm font-medium text-heading">Card example with CTA button:</p>
@@ -406,77 +376,43 @@ function Component() {
406
376
  </div>
407
377
  <p class="mt-2.5 text-sm text-body">Configure Tailwind CSS and Flowbite before copying the code</p>
408
378
  </div>
409
- {{< /example >}}
410
-
411
- ## Card with API keys
412
-
413
- Use this example to show multiple input field elements that have the copy to clipboard button inside a card component for more complex applications where you need to copy API keys, account IDs and more.
379
+ ```
414
380
 
415
- Make sure that you also apply the custom JavaScript code with the function callback to enable the success and default message states for each input field and copy button.
416
-
417
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="580" javascript=`
418
- window.addEventListener('load', function() {
419
- const clipboardAccountID = FlowbiteInstances.getInstance('CopyClipboard', 'account-id');
420
- const clipboardExternalID = FlowbiteInstances.getInstance('CopyClipboard', 'api-key');
421
- const clipboardRoleARN = FlowbiteInstances.getInstance('CopyClipboard', 'role-arn');
422
-
423
- const tooltipAccountID = FlowbiteInstances.getInstance('Tooltip', 'tooltip-account-id');
424
- const tooltipExternalID = FlowbiteInstances.getInstance('Tooltip', 'tooltip-api-key');
425
- const tooltipRoleARN = FlowbiteInstances.getInstance('Tooltip', 'tooltip-role-arn');
381
+ ```javascript
382
+ window.addEventListener('load', function () {
383
+ const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'code-block');
426
384
 
427
- const clipboards = [
428
- {
429
- clipboard: clipboardAccountID,
430
- tooltip: tooltipAccountID,
431
- defaultMessage: document.getElementById('default-tooltip-message-account-id'),
432
- successMessage: document.getElementById('success-tooltip-message-account-id'),
433
- defaultIcon: document.getElementById('default-icon-account-id'),
434
- successIcon: document.getElementById('success-icon-account-id')
435
- },
436
- {
437
- clipboard: clipboardExternalID,
438
- tooltip: tooltipExternalID,
439
- defaultMessage: document.getElementById('default-tooltip-message-api-key'),
440
- successMessage: document.getElementById('success-tooltip-message-api-key'),
441
- defaultIcon: document.getElementById('default-icon-api-key'),
442
- successIcon: document.getElementById('success-icon-api-key')
443
- },
444
- {
445
- clipboard: clipboardRoleARN,
446
- tooltip: tooltipRoleARN,
447
- defaultMessage: document.getElementById('default-tooltip-message-role-arn'),
448
- successMessage: document.getElementById('success-tooltip-message-role-arn'),
449
- defaultIcon: document.getElementById('default-icon-role-arn'),
450
- successIcon: document.getElementById('success-icon-role-arn')
451
- }
452
- ]
385
+ const $defaultMessage = document.getElementById('default-message');
386
+ const $successMessage = document.getElementById('success-message');
453
387
 
454
- clipboards.forEach((item) => {
455
- item.clipboard.updateOnCopyCallback(() => {
456
- showSuccess(item.defaultMessage, item.successMessage);
457
- showSuccess(item.defaultIcon, item.successIcon);
458
- item.tooltip.show();
388
+ clipboard.updateOnCopyCallback((clipboard) => {
389
+ showSuccess();
459
390
 
460
- // reset to default state
461
- setTimeout(() => {
462
- resetToDefault(item.defaultMessage, item.successMessage);
463
- resetToDefault(item.defaultIcon, item.successIcon);
464
- item.tooltip.hide();
465
- }, 2000);
466
- })
391
+ // reset to default state
392
+ setTimeout(() => {
393
+ resetToDefault();
394
+ }, 2000);
467
395
  })
468
396
 
469
- const showSuccess = ($defaultEl, $successEl) => {
470
- $defaultEl.classList.add('hidden');
471
- $successEl.classList.remove('hidden');
397
+ const showSuccess = () => {
398
+ $defaultMessage.classList.add('hidden');
399
+ $successMessage.classList.remove('hidden');
472
400
  }
473
401
 
474
- const resetToDefault = ($defaultEl, $successEl) => {
475
- $defaultEl.classList.remove('hidden');
476
- $successEl.classList.add('hidden');
402
+ const resetToDefault = () => {
403
+ $defaultMessage.classList.remove('hidden');
404
+ $successMessage.classList.add('hidden');
477
405
  }
478
406
  })
479
- ` >}}
407
+ ```
408
+
409
+ ## Card with API keys
410
+
411
+ Use this example to show multiple input field elements that have the copy to clipboard button inside a card component for more complex applications where you need to copy API keys, account IDs and more.
412
+
413
+ Make sure that you also apply the custom JavaScript code with the function callback to enable the success and default message states for each input field and copy button.
414
+
415
+ ```html
480
416
  <div class="w-full max-w-lg bg-neutral-primary-soft border border-default shadow-xs rounded-base p-4 sm:p-6">
481
417
  <h2 class="text-lg font-semibold text-heading mb-2">Create a role with read only in-line policies</h2>
482
418
  <p class="text-body mb-6">To give Flowbite read access, please create an IAM Role following <a href="#" class="text-fg-brand underline hover:no-underline font-medium">trust relationship</a> and <a href="#" class="text-fg-brand underline hover:no-underline font-medium">inline policy</a>.</p>
@@ -536,51 +472,79 @@ window.addEventListener('load', function() {
536
472
  <button type="button" class="text-white bg-brand box-border border border-transparent hover:bg-brand-strong focus:ring-4 focus:ring-brand-medium shadow-xs font-medium leading-5 rounded-base text-sm px-4 py-2.5 focus:outline-none">Next step</button>
537
473
  </div>
538
474
  </div>
539
- {{< /example >}}
540
-
541
- ## Copy contact details
542
-
543
- This example can be used to copy the text content (ie. contact details) inside of the `<address>` field by clicking on the copy to clipboard button positioned inside of the address card.
544
-
545
- Make sure that you set the `data-copy-to-clipboard-content-type="textContent"` data attribute to the trigger element (ie. the button) to specify the source of the content that is to be copied.
475
+ ```
546
476
 
547
- {{< example class="flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="380" javascript=`
477
+ ```javascript
548
478
  window.addEventListener('load', function() {
549
- const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'contact-details');
550
- const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-contact-details');
479
+ const clipboardAccountID = FlowbiteInstances.getInstance('CopyClipboard', 'account-id');
480
+ const clipboardExternalID = FlowbiteInstances.getInstance('CopyClipboard', 'api-key');
481
+ const clipboardRoleARN = FlowbiteInstances.getInstance('CopyClipboard', 'role-arn');
551
482
 
552
- const $defaultIcon = document.getElementById('default-icon-contact-details');
553
- const $successIcon = document.getElementById('success-icon-contact-details');
483
+ const tooltipAccountID = FlowbiteInstances.getInstance('Tooltip', 'tooltip-account-id');
484
+ const tooltipExternalID = FlowbiteInstances.getInstance('Tooltip', 'tooltip-api-key');
485
+ const tooltipRoleARN = FlowbiteInstances.getInstance('Tooltip', 'tooltip-role-arn');
554
486
 
555
- const $defaultTooltipMessage = document.getElementById('default-tooltip-message-contact-details');
556
- const $successTooltipMessage = document.getElementById('success-tooltip-message-contact-details');
487
+ const clipboards = [
488
+ {
489
+ clipboard: clipboardAccountID,
490
+ tooltip: tooltipAccountID,
491
+ defaultMessage: document.getElementById('default-tooltip-message-account-id'),
492
+ successMessage: document.getElementById('success-tooltip-message-account-id'),
493
+ defaultIcon: document.getElementById('default-icon-account-id'),
494
+ successIcon: document.getElementById('success-icon-account-id')
495
+ },
496
+ {
497
+ clipboard: clipboardExternalID,
498
+ tooltip: tooltipExternalID,
499
+ defaultMessage: document.getElementById('default-tooltip-message-api-key'),
500
+ successMessage: document.getElementById('success-tooltip-message-api-key'),
501
+ defaultIcon: document.getElementById('default-icon-api-key'),
502
+ successIcon: document.getElementById('success-icon-api-key')
503
+ },
504
+ {
505
+ clipboard: clipboardRoleARN,
506
+ tooltip: tooltipRoleARN,
507
+ defaultMessage: document.getElementById('default-tooltip-message-role-arn'),
508
+ successMessage: document.getElementById('success-tooltip-message-role-arn'),
509
+ defaultIcon: document.getElementById('default-icon-role-arn'),
510
+ successIcon: document.getElementById('success-icon-role-arn')
511
+ }
512
+ ]
557
513
 
558
- clipboard.updateOnCopyCallback((clipboard) => {
559
- showSuccess();
514
+ clipboards.forEach((item) => {
515
+ item.clipboard.updateOnCopyCallback(() => {
516
+ showSuccess(item.defaultMessage, item.successMessage);
517
+ showSuccess(item.defaultIcon, item.successIcon);
518
+ item.tooltip.show();
560
519
 
561
- // reset to default state
562
- setTimeout(() => {
563
- resetToDefault();
564
- }, 2000);
520
+ // reset to default state
521
+ setTimeout(() => {
522
+ resetToDefault(item.defaultMessage, item.successMessage);
523
+ resetToDefault(item.defaultIcon, item.successIcon);
524
+ item.tooltip.hide();
525
+ }, 2000);
526
+ })
565
527
  })
566
528
 
567
- const showSuccess = () => {
568
- $defaultIcon.classList.add('hidden');
569
- $successIcon.classList.remove('hidden');
570
- $defaultTooltipMessage.classList.add('hidden');
571
- $successTooltipMessage.classList.remove('hidden');
572
- tooltip.show();
529
+ const showSuccess = ($defaultEl, $successEl) => {
530
+ $defaultEl.classList.add('hidden');
531
+ $successEl.classList.remove('hidden');
573
532
  }
574
533
 
575
- const resetToDefault = () => {
576
- $defaultIcon.classList.remove('hidden');
577
- $successIcon.classList.add('hidden');
578
- $defaultTooltipMessage.classList.remove('hidden');
579
- $successTooltipMessage.classList.add('hidden');
580
- tooltip.hide();
534
+ const resetToDefault = ($defaultEl, $successEl) => {
535
+ $defaultEl.classList.remove('hidden');
536
+ $successEl.classList.add('hidden');
581
537
  }
582
538
  })
583
- ` >}}
539
+ ```
540
+
541
+ ## Copy contact details
542
+
543
+ This example can be used to copy the text content (ie. contact details) inside of the `<address>` field by clicking on the copy to clipboard button positioned inside of the address card.
544
+
545
+ Make sure that you set the `data-copy-to-clipboard-content-type="textContent"` data attribute to the trigger element (ie. the button) to specify the source of the content that is to be copied.
546
+
547
+ ```html
584
548
  <div class="w-full max-w-md bg-neutral-primary-soft border border-default shadow-xs rounded-base p-4 sm:p-6">
585
549
  <h2 class="text-lg font-semibold text-heading mb-4">Contact details</h2>
586
550
  <address class="relative bg-neutral-secondary-medium p-4 rounded-base border border-default-medium font-italic grid grid-cols-2">
@@ -609,22 +573,18 @@ window.addEventListener('load', function() {
609
573
  </div>
610
574
  </address>
611
575
  </div>
612
- {{< /example >}}
613
-
614
- ## Copy button with modal
615
-
616
- Use this example to show an input field where you can copy the URL of the current page and also show a modal with the copied URL when the copy button is clicked.
576
+ ```
617
577
 
618
- {{< example class="bg-neutral-primary flex justify-center items-center h-full" github="components/clipboard.md" show_dark=true iframeHeight="580" javascript=`
578
+ ```javascript
619
579
  window.addEventListener('load', function() {
620
- const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'course-url');
621
- const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-course-url');
580
+ const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'contact-details');
581
+ const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-contact-details');
622
582
 
623
- const $defaultIcon = document.getElementById('default-icon-course-url');
624
- const $successIcon = document.getElementById('success-icon-course-url');
583
+ const $defaultIcon = document.getElementById('default-icon-contact-details');
584
+ const $successIcon = document.getElementById('success-icon-contact-details');
625
585
 
626
- const $defaultTooltipMessage = document.getElementById('default-tooltip-message-course-url');
627
- const $successTooltipMessage = document.getElementById('success-tooltip-message-course-url');
586
+ const $defaultTooltipMessage = document.getElementById('default-tooltip-message-contact-details');
587
+ const $successTooltipMessage = document.getElementById('success-tooltip-message-contact-details');
628
588
 
629
589
  clipboard.updateOnCopyCallback((clipboard) => {
630
590
  showSuccess();
@@ -651,7 +611,13 @@ window.addEventListener('load', function() {
651
611
  tooltip.hide();
652
612
  }
653
613
  })
654
- ` >}}
614
+ ```
615
+
616
+ ## Copy button with modal
617
+
618
+ Use this example to show an input field where you can copy the URL of the current page and also show a modal with the copied URL when the copy button is clicked.
619
+
620
+ ```html
655
621
  <button type="button" data-modal-target="course-modal" data-modal-toggle="course-modal" class="inline-flex items-center text-body bg-neutral-secondary-medium box-border border border-default-medium hover:bg-neutral-tertiary-medium hover:text-heading focus:ring-4 focus:ring-neutral-tertiary shadow-xs font-medium leading-5 rounded-base text-sm px-4 py-2.5 focus:outline-none">
656
622
  <svg class="w-4 h-4 me-1.5 -ms-0.5" 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-width="2" d="M7.926 10.898 15 7.727m-7.074 5.39L15 16.29M8 12a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Zm12 5.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Zm0-11a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Z"/></svg>
657
623
  Share course
@@ -696,7 +662,45 @@ window.addEventListener('load', function() {
696
662
  </div>
697
663
  </div>
698
664
  </div>
699
- {{< /example >}}
665
+ ```
666
+
667
+ ```javascript
668
+ window.addEventListener('load', function() {
669
+ const clipboard = FlowbiteInstances.getInstance('CopyClipboard', 'course-url');
670
+ const tooltip = FlowbiteInstances.getInstance('Tooltip', 'tooltip-course-url');
671
+
672
+ const $defaultIcon = document.getElementById('default-icon-course-url');
673
+ const $successIcon = document.getElementById('success-icon-course-url');
674
+
675
+ const $defaultTooltipMessage = document.getElementById('default-tooltip-message-course-url');
676
+ const $successTooltipMessage = document.getElementById('success-tooltip-message-course-url');
677
+
678
+ clipboard.updateOnCopyCallback((clipboard) => {
679
+ showSuccess();
680
+
681
+ // reset to default state
682
+ setTimeout(() => {
683
+ resetToDefault();
684
+ }, 2000);
685
+ })
686
+
687
+ const showSuccess = () => {
688
+ $defaultIcon.classList.add('hidden');
689
+ $successIcon.classList.remove('hidden');
690
+ $defaultTooltipMessage.classList.add('hidden');
691
+ $successTooltipMessage.classList.remove('hidden');
692
+ tooltip.show();
693
+ }
694
+
695
+ const resetToDefault = () => {
696
+ $defaultIcon.classList.remove('hidden');
697
+ $successIcon.classList.add('hidden');
698
+ $defaultTooltipMessage.classList.remove('hidden');
699
+ $successTooltipMessage.classList.add('hidden');
700
+ tooltip.hide();
701
+ }
702
+ })
703
+ ```
700
704
 
701
705
  ## JavaScript behaviour
702
706
 
@@ -899,7 +903,7 @@ Use the following methods from the CopyClipboard component to programmatically w
899
903
 
900
904
  Check out the following example to learn how to create a new CopyClipboard component via the Flowbite JavaScript API and set up the class, options, and methods to programmatically work with the component.
901
905
 
902
- {{< code lang="javascript" file="clipboard.js" icon="file" >}}
906
+ ```javascript
903
907
  // set the trigger element such as a button or text field
904
908
  const $triggerEl = document.getElementById('copy-clipboard-button');
905
909
 
@@ -919,11 +923,11 @@ const instanceOptions = {
919
923
  id: 'copy-clipboard-example',
920
924
  override: true
921
925
  };
922
- {{< /code >}}
926
+ ```
923
927
 
924
928
  Next step is to create a new instance of a CopyClipboard object using the parameters we have set above.
925
929
 
926
- {{< code lang="javascript" file="clipboard.js" icon="file" >}}
930
+ ```javascript
927
931
  import { CopyClipboard } from 'flowbite';
928
932
 
929
933
  /*
@@ -933,19 +937,19 @@ import { CopyClipboard } from 'flowbite';
933
937
  * instanceOptions: optional
934
938
  */
935
939
  const clipboard = new CopyClipboard($triggerEl, $targetEl, options, instanceOptions);
936
- {{< /code >}}
940
+ ```
937
941
 
938
942
  Set the event listeners on the button to copy the text from the input field:
939
943
 
940
- {{< code lang="javascript" file="clipboard.js" icon="file" >}}
944
+ ```javascript
941
945
  $triggerEl.addEventListener('click', () => {
942
946
  clipboard.copy();
943
947
  });
944
- {{< /code >}}
948
+ ```
945
949
 
946
950
  Now you can programmatically call the methods of the CopyClipboard component:
947
951
 
948
- {{< code lang="javascript" file="clipboard.js" icon="file" >}}
952
+ ```javascript
949
953
  // get the value, inner HTML or text content of the target element
950
954
  clipboard.getTargetValue();
951
955
 
@@ -957,13 +961,13 @@ clipboard.updateOnCopyCallback(() => {
957
961
  // do something when the text has been copied to the clipboard
958
962
  console.log('updated on copy callback success message');
959
963
  });
960
- {{< /code >}}
964
+ ```
961
965
 
962
966
  ### HTML Markup
963
967
 
964
968
  Here is an example of the HTML markup that you can use for the JavaScript example above.
965
969
 
966
- {{< code lang="html" file="clipboard.html" icon="file" >}}
970
+ ```html
967
971
  <div class="grid grid-cols-8 gap-2 w-full max-w-[23rem]">
968
972
  <label for="copy-text" class="sr-only">Label</label>
969
973
  <input id="copy-text" type="text" class="col-span-6 bg-gray-50 border border-gray-300 text-gray-500 text-sm rounded-base focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-gray-400 dark:focus:ring-blue-500 dark:focus:border-blue-500" value="npm install flowbite" disabled readonly>
@@ -977,15 +981,15 @@ Here is an example of the HTML markup that you can use for the JavaScript exampl
977
981
  </span>
978
982
  </button>
979
983
  </div>
980
- {{< /code >}}
984
+ ```
981
985
 
982
986
  ### TypeScript
983
987
 
984
- If you're using the <a href="{{< ref "getting-started/typescript" >}}">TypeScript configuration</a> from Flowbite then you can import the types for the CopyClipboard object, parameters and its options.
988
+ If you're using the TypeScript configuration from Flowbite then you can import the types for the CopyClipboard object, parameters and its options.
985
989
 
986
990
  Here's an example that applies the types from Flowbite to the code above:
987
991
 
988
- {{< code lang="typescript" file="clipboard.ts" icon="file" >}}
992
+ ```typescript
989
993
  import { CopyClipboard } from 'flowbite';
990
994
  import type { CopyClipboardOptions, CopyClipboardInterface } from 'flowbite';
991
995
  import type { InstanceOptions } from 'flowbite';
@@ -1026,4 +1030,4 @@ const clipboard: CopyClipboardInterface = new CopyClipboard(
1026
1030
 
1027
1031
  // copy the value of the target element
1028
1032
  clipboard.copy();
1029
- {{< /code >}}
1033
+ ```