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,673 @@
1
+ ---
2
+ layout: docs
3
+ title: Tailwind CSS Datepicker - Flowbite
4
+ description: Start receiving date and time data from your users using this free datepicker element based on Tailwind utility-classes and vanilla JavaScript
5
+ group: components
6
+ toc: true
7
+ requires_js: true
8
+
9
+ previous: Clipboard
10
+ previousLink: components/clipboard/
11
+ next: Device mockups
12
+ nextLink: components/device-mockups/
13
+ ---
14
+
15
+ The Tailwind CSS datepicker component developed by Flowbite is built with vanilla JavaScript and using the utility-first classes from Tailwind. The datepicker features both inline and a date range picker functionality and some extra options such as autohide, custom format, positioning, and more. Check out the [timepicker component](https://flowbite.com/docs/forms/timepicker/) to select time alongside dates.
16
+
17
+ ## Getting started
18
+
19
+ If you want to use the datepicker component from Flowbite you have to include the Flowbite JavaScript file either via NPM or CDN. For versions before `2.4.0` please continue using the dedicated CDN and component.
20
+
21
+ Follow the [quickstart guide]({{< ref "getting-started/quickstart" >}}) and then include the following JavaScript file:
22
+
23
+ {{< code lang="html" file="index.html" icon="file" >}}
24
+ <script src="../path/to/flowbite/dist/flowbite.min.js"></script>
25
+ {{< /code >}}
26
+
27
+ Alternatively you can also use CDN to include the datepicker JavaScript.
28
+
29
+ {{< code lang="html" file="index.html" icon="file" >}}
30
+ <script src="https://cdn.jsdelivr.net/npm/flowbite@{{< current_version >}}/dist/flowbite.min.js"></script>
31
+ {{< /code >}}
32
+
33
+ Also make sure that you add the source files for Tailwind in your main CSS file:
34
+
35
+ {{< code lang="css" file="style.css" icon="file" >}}
36
+ @import "tailwindcss";
37
+
38
+ @source "../node_modules/flowbite-datepicker";
39
+ {{< /code >}}
40
+
41
+ If you'd like to manually be able to manipulate the datepicker component using JavaScript then you should <a href="#javascript">install the component using NPM</a> and include it into your JavaScript code.
42
+
43
+ ## Datepicker example
44
+
45
+ Use the following example of an input element to create a datepicker component. All you need to do is to add the `datepicker` data attribute to any `input` element.
46
+
47
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true iframeHeight="500" initDatepicker=true >}}
48
+ <div class="relative max-w-sm">
49
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
50
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
51
+ </div>
52
+ <input datepicker id="default-datepicker" type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date">
53
+ </div>
54
+ {{< /example >}}
55
+
56
+ ## Inline datepicker
57
+
58
+ Use the `inline-datepicker` and `data-date` data attributes to initialize and set the default date for an inline datepicker inside a block element such as a `div`.
59
+
60
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true initDatepicker=true >}}
61
+ <div id="datepicker-inline" inline-datepicker data-date="02/25/2024"></div>
62
+ {{< /example >}}
63
+
64
+ ## Date range picker
65
+
66
+ Use the `date-rangepicker` data attribute and the following markup to initialize two datepickers as a range.
67
+
68
+ {{< example class="flex justify-center " github="components/datepicker.md" show_dark=true iframeHeight="480" initDatepicker=true >}}
69
+ <div id="date-range-picker" date-rangepicker class="flex items-center">
70
+ <div class="relative">
71
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
72
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
73
+ </div>
74
+ <input id="datepicker-range-start" name="start" type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date start">
75
+ </div>
76
+ <span class="mx-4 text-body">to</span>
77
+ <div class="relative">
78
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
79
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
80
+ </div>
81
+ <input id="datepicker-range-end" name="end" type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date end">
82
+ </div>
83
+ </div>
84
+ {{< /example >}}
85
+
86
+ ## Options
87
+
88
+ Learn more about the options that you can use with the Tailwind datepicker to enable features such as autohide, action buttons, date format, orientation, and more based on the vanilla JavaScript from Flowbite.
89
+
90
+ ### Autohide
91
+
92
+ Use the `datepicker-autohide` data attribute to make the datepicker disappear right after selecting a date.
93
+
94
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true iframeHeight="480" initDatepicker=true >}}
95
+ <div class="relative max-w-sm">
96
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
97
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
98
+ </div>
99
+ <input id="datepicker-autohide" datepicker datepicker-autohide type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date">
100
+ </div>
101
+ {{< /example >}}
102
+
103
+ ### Action buttons
104
+
105
+ By adding the `datepicker-buttons` data attribute you will enable the `today` and `clear` buttons:
106
+
107
+ - clicking on the `today` button will browse back to the current day/month/year
108
+ - clicking on the `clear` button will reset all selections
109
+
110
+ If you want the button to additionally select today's date, add `datepicker-autoselect-today` data attribute.
111
+
112
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true iframeHeight="530" initDatepicker=true >}}
113
+ <div class="relative max-w-sm">
114
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
115
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
116
+ </div>
117
+ <input id="datepicker-actions" datepicker datepicker-buttons datepicker-autoselect-today type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date">
118
+ </div>
119
+ {{< /example >}}
120
+
121
+ ### Date format
122
+
123
+ If you want to use a custom format such as `mm-dd-yyyy`then you can use the `datepicker-format="{format}"` data attribute to change it.
124
+
125
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true iframeHeight="480" initDatepicker=true >}}
126
+ <div class="relative max-w-sm">
127
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
128
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
129
+ </div>
130
+ <input id="datepicker-format" datepicker datepicker-format="mm-dd-yyyy" type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date">
131
+ </div>
132
+ {{< /example >}}
133
+
134
+ ### Max and min dates
135
+
136
+ Use the `datepicker-min-date={format}` and `datepicker-max-date={format}` to set the minimum and maximum dates that can be selected inside the datepicker.
137
+
138
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true iframeHeight="480" initDatepicker=true >}}
139
+ <div class="relative max-w-sm">
140
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
141
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
142
+ </div>
143
+ <input id="datepicker-format" datepicker datepicker-min-date="06/04/2024" datepicker-max-date="05/05/2025" type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date">
144
+ </div>
145
+ {{< /example >}}
146
+
147
+ ### Orientation
148
+
149
+ You can override the default positioning algorithm by using the `datepicker-orientation="{top|right|bottom|left}"` data attributes. You can even combine right with bottom or left with top.
150
+
151
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true iframeHeight="480" initDatepicker=true >}}
152
+ <div class="relative max-w-sm">
153
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
154
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
155
+ </div>
156
+ <input id="datepicker-orientation" datepicker datepicker-orientation="bottom right" type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date">
157
+ </div>
158
+ {{< /example >}}
159
+
160
+ ### Title
161
+
162
+ You can also add a title to the datepicker by using the `datepicker-title="{title}"` data attribute.
163
+
164
+ {{< example class="flex justify-center bg-neutral-primary" github="components/datepicker.md" show_dark=true iframeHeight="530" initDatepicker=true >}}
165
+ <div class="relative max-w-sm">
166
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
167
+ <svg class="w-4 h-4 text-body" 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="M4 10h16m-8-3V4M7 7V4m10 3V4M5 20h14a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1Zm3-7h.01v.01H8V13Zm4 0h.01v.01H12V13Zm4 0h.01v.01H16V13Zm-8 4h.01v.01H8V17Zm4 0h.01v.01H12V17Zm4 0h.01v.01H16V17Z"/></svg>
168
+ </div>
169
+ <input id="datepicker-title" datepicker datepicker-title="Flowbite datepicker" type="text" class="block w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" placeholder="Select date">
170
+ </div>
171
+ {{< /example >}}
172
+
173
+ ### Custom colors
174
+
175
+ You can set the `primary` color class which is by default set to blue to add your own colors.
176
+
177
+ ### Language (i18n)
178
+
179
+ We are working on the API to provide language support for the datepicker.
180
+
181
+ Until then, please refer to this [solution from GitHub](https://github.com/themesberg/flowbite/issues/32#issuecomment-1420422922).
182
+
183
+ ## Timepicker
184
+
185
+ Use the native browser timepicker input field to select a time alongside the datepicker. Check out more examples on the [timepicker](https://flowbite.com/docs/forms/timepicker/) component page from Flowbite.
186
+
187
+ {{< example github="components/timepicker.md" show_dark=true >}}
188
+ <form class="max-w-[8rem] mx-auto">
189
+ <label for="time" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Select time:</label>
190
+ <div class="relative">
191
+ <div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
192
+ <svg class="w-4 h-4 text-body" 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="M12 8v4l3 3m6-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/></svg>
193
+ </div>
194
+ <input type="time" id="time" class="block w-full px-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand px-3 py-2.5 shadow-xs placeholder:text-body" min="09:00" max="18:00" value="00:00" required />
195
+ </div>
196
+ </form>
197
+ {{< /example >}}
198
+
199
+ ## Dark mode
200
+
201
+ If you would like to enable dark mode for the datepicker please follow the [dark mode]({{< ref "customize/dark-mode" >}}) guide on Flowbite and enable it either manually or by using a dark mode switcher.
202
+
203
+ ## JavaScript Behaviour
204
+
205
+ Use the **Tailwind CSS Datepicker** component from Flowbite to select a date or range of dates based on the Datepicker API and configure the component using the methods and options that you can pass when creating the object using JavaScript.
206
+
207
+ ### Object parameters
208
+
209
+ Use the object parameters from the Datepicker component to set the datepicker parent input element and the options associated with it when creating a new instance.
210
+
211
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
212
+ <table class="w-full text-sm text-left text-body">
213
+ <thead class="bg-neutral-secondary-soft text-heading">
214
+ <tr class="text-xs uppercase">
215
+ <th scope="col" class="px-6 py-3">
216
+ Parameter
217
+ </th>
218
+ <th scope="col" class="px-6 py-3">
219
+ Type
220
+ </th>
221
+ <th scope="col" class="px-6 py-3">
222
+ Required
223
+ </th>
224
+ <th scope="col" class="px-6 py-3">
225
+ Description
226
+ </th>
227
+ </tr>
228
+ </thead>
229
+ <tbody>
230
+ <tr class="border-b bg-neutral-primary border-default">
231
+ <td class="px-6 py-4 ">
232
+ <code class="text-fg-brand">datepickerEl</code>
233
+ </td>
234
+ <td class="px-6 py-4">
235
+ Element
236
+ </td>
237
+ <td class="px-6 py-4">
238
+ Required
239
+ </td>
240
+ <td class="px-6 py-4">
241
+ Pass the main HTML element that will be rendered for the datepicker. It can be an input element or a `div` for inline rendering.
242
+ </td>
243
+ </tr>
244
+ <tr class="border-b bg-neutral-primary border-default">
245
+ <td class="px-6 py-4 ">
246
+ <code class="text-fg-brand">options</code>
247
+ </td>
248
+ <td class="px-6 py-4">
249
+ Object
250
+ </td>
251
+ <td class="px-6 py-4">
252
+ Optional
253
+ </td>
254
+ <td class="px-6 py-4">
255
+ Use the options parameter to set custom datepicker options such as the default date, minimum and maximum values, action buttons and callback functions.
256
+ </td>
257
+ </tr>
258
+ <tr class="bg-neutral-primary">
259
+ <td class="px-6 py-4 font-medium">
260
+ <code class="text-fg-brand">instanceOptions</code>
261
+ </td>
262
+ <td class="px-6 py-4">
263
+ Object
264
+ </td>
265
+ <td class="px-6 py-4">
266
+ Optional
267
+ </td>
268
+ <td class="px-6 py-4">
269
+ 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.
270
+ </td>
271
+ </tr>
272
+ </tbody>
273
+ </table>
274
+ </div>
275
+
276
+ ### Options
277
+
278
+ Use these optional options for the Datepicker object to set options such as the date format, orientation, max and min dates, custom buttons, callback functions and more.
279
+
280
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
281
+ <table class="w-full text-sm text-left text-body">
282
+ <thead class="bg-neutral-secondary-soft text-heading">
283
+ <tr class="text-xs uppercase">
284
+ <th scope="col" class="px-6 py-3">
285
+ Option
286
+ </th>
287
+ <th scope="col" class="px-6 py-3">
288
+ Type
289
+ </th>
290
+ <th scope="col" class="px-6 py-3">
291
+ Description
292
+ </th>
293
+ </tr>
294
+ </thead>
295
+ <tbody>
296
+ <tr class="border-b bg-neutral-primary border-default">
297
+ <td class="px-6 py-4 ">
298
+ <code class="text-fg-brand">rangePicker</code>
299
+ </td>
300
+ <td class="px-6 py-4 ">
301
+ Boolean
302
+ </td>
303
+ <td class="px-6 py-4">
304
+ If set to true then the datepicker will be converted to a date range picker. By default it's false.
305
+ </td>
306
+ </tr>
307
+ <tr class="border-b bg-neutral-primary border-default">
308
+ <td class="px-6 py-4 ">
309
+ <code class="text-fg-brand">format</code>
310
+ </td>
311
+ <td class="px-6 py-4 ">
312
+ String
313
+ </td>
314
+ <td class="px-6 py-4">
315
+ Use this option to set a custom format for the datepicker. By default it's `mm/dd/yyyy`.
316
+ </td>
317
+ </tr>
318
+ <tr class="border-b bg-neutral-primary border-default">
319
+ <td class="px-6 py-4 ">
320
+ <code class="text-fg-brand">maxDate</code>
321
+ </td>
322
+ <td class="px-6 py-4 ">
323
+ String
324
+ </td>
325
+ <td class="px-6 py-4">
326
+ Use this option to set the maximum selectable date of the datepicker component.
327
+ </td>
328
+ </tr>
329
+ <tr class="border-b bg-neutral-primary border-default">
330
+ <td class="px-6 py-4 ">
331
+ <code class="text-fg-brand">minDate</code>
332
+ </td>
333
+ <td class="px-6 py-4 ">
334
+ String
335
+ </td>
336
+ <td class="px-6 py-4">
337
+ Use this option to set the minimum selectable date of the datepicker component.
338
+ </td>
339
+ </tr>
340
+ <tr class="border-b bg-neutral-primary border-default">
341
+ <td class="px-6 py-4 ">
342
+ <code class="text-fg-brand">orientation</code>
343
+ </td>
344
+ <td class="px-6 py-4 ">
345
+ String
346
+ </td>
347
+ <td class="px-6 py-4">
348
+ Set the orientation of the datepicker component when it's not inline. It can be top, bottom, left, or right.
349
+ </td>
350
+ </tr>
351
+ <tr class="border-b bg-neutral-primary border-default">
352
+ <td class="px-6 py-4 ">
353
+ <code class="text-fg-brand">buttons</code>
354
+ </td>
355
+ <td class="px-6 py-4 ">
356
+ Boolean
357
+ </td>
358
+ <td class="px-6 py-4">
359
+ If set to true then the "today" and "clear" action buttons will be shown that lets you select today's date or clear selections.
360
+ </td>
361
+ </tr>
362
+ <tr class="border-b bg-neutral-primary border-default">
363
+ <td class="px-6 py-4 ">
364
+ <code class="text-fg-brand">autoSelectToday</code>
365
+ </td>
366
+ <td class="px-6 py-4 ">
367
+ Integer
368
+ </td>
369
+ <td class="px-6 py-4">
370
+ If set to 1 then it will automatically have today's date preselected.
371
+ </td>
372
+ </tr>
373
+ <tr class="bg-neutral-primary">
374
+ <td class="px-6 py-4 ">
375
+ <code class="text-fg-brand">title</code>
376
+ </td>
377
+ <td class="px-6 py-4 ">
378
+ String
379
+ </td>
380
+ <td class="px-6 py-4">
381
+ Set a custom title for the datepicker component. By default it's null.
382
+ </td>
383
+ </tr>
384
+ <!-- <tr class="border-b bg-neutral-primary border-default">
385
+ <td class="px-6 py-4 ">
386
+ <code class="text-fg-brand">language</code>
387
+ </td>
388
+ <td class="px-6 py-4 ">
389
+ String
390
+ </td>
391
+ <td class="px-6 py-4">
392
+ Set the language of the datepicker using country codes like `es`, `fr`, or `de`. By default it's set to english.
393
+ </td>
394
+ </tr> -->
395
+ </tbody>
396
+ </table>
397
+ </div>
398
+
399
+ ### Methods
400
+
401
+ Use the following methods of the Datepicker object to programmatically manipulate the behaviour.
402
+
403
+ <div class="relative my-10 overflow-x-auto shadow-xs rounded-base border border-default">
404
+ <table class="w-full text-sm text-left text-body">
405
+ <thead class="bg-neutral-secondary-soft text-heading">
406
+ <tr class="text-xs uppercase">
407
+ <th scope="col" class="px-6 py-3">
408
+ Method
409
+ </th>
410
+ <th scope="col" class="px-6 py-3">
411
+ Description
412
+ </th>
413
+ </tr>
414
+ </thead>
415
+ <tbody>
416
+ <tr class="border-b bg-neutral-primary border-default">
417
+ <td class="px-6 py-4 ">
418
+ <code class="text-fg-brand">getDate()</code>
419
+ </td>
420
+ <td class="px-6 py-4">
421
+ Use this method to get the currenctly select date from the datepicker.
422
+ </td>
423
+ </tr>
424
+ <tr class="border-b bg-neutral-primary border-default">
425
+ <td class="px-6 py-4 ">
426
+ <code class="text-fg-brand">setDate()</code>
427
+ </td>
428
+ <td class="px-6 py-4">
429
+ Use this method to set the date value of the datepicker component.
430
+ </td>
431
+ </tr>
432
+ <tr class="border-b bg-neutral-primary border-default">
433
+ <td class="px-6 py-4 ">
434
+ <code class="text-fg-brand">show()</code>
435
+ </td>
436
+ <td class="px-6 py-4">
437
+ Use this function to programatically show the datepicker component.
438
+ </td>
439
+ </tr>
440
+ <tr class="border-b bg-neutral-primary border-default">
441
+ <td class="px-6 py-4 ">
442
+ <code class="text-fg-brand">hide()</code>
443
+ </td>
444
+ <td class="px-6 py-4">
445
+ Use this function to programatically hide the datepicker component.
446
+ </td>
447
+ </tr>
448
+ <tr class="border-b bg-neutral-primary border-default">
449
+ <td class="px-6 py-4 ">
450
+ <code class="text-fg-brand">getDatepickerInstance()</code>
451
+ </td>
452
+ <td class="px-6 py-4">
453
+ Use this method to get the parent datepicker instance with the extended collection of methods and options.
454
+ </td>
455
+ </tr>
456
+ <tr class="border-b bg-neutral-primary border-default">
457
+ <td class="px-6 py-4 ">
458
+ <code class="text-fg-brand">updateOnShow(callback)</code>
459
+ </td>
460
+ <td class="px-6 py-4">
461
+ Use this method to set a callback function whenever the datepicker component has been shown.
462
+ </td>
463
+ </tr>
464
+ <tr class="bg-neutral-primary">
465
+ <td class="px-6 py-4 ">
466
+ <code class="text-fg-brand">updateOnHide(callback)</code>
467
+ </td>
468
+ <td class="px-6 py-4">
469
+ Use this method to set a callback function whenever the datepicker component has been hidden.
470
+ </td>
471
+ </tr>
472
+ </tbody>
473
+ </table>
474
+ </div>
475
+
476
+ ### Example
477
+
478
+ Check out the following examples to learn how to use a basic HTML markup together with the Flowbite Datepicker API JS.
479
+
480
+ First of all, you need to select the datepicker element (it can be an input field or div for inline datepickers) and set up the options object.
481
+
482
+ {{< code lang="javascript" file="datepicker.js" icon="file" >}}
483
+ // set the target element of the input field
484
+ const $datepickerEl = document.getElementById('datepicker-custom');
485
+
486
+ // optional options with default values and callback functions
487
+ const options = {
488
+ defaultDatepickerId: null,
489
+ autohide: false,
490
+ format: 'mm/dd/yyyy',
491
+ maxDate: null,
492
+ minDate: null,
493
+ orientation: 'bottom',
494
+ buttons: false,
495
+ autoSelectToday: false,
496
+ title: null,
497
+ rangePicker: false,
498
+ onShow: () => {},
499
+ onHide: () => {},
500
+ };
501
+
502
+ const instanceOptions = {
503
+ id: 'datepicker-custom-example',
504
+ override: true
505
+ };
506
+ {{< /code >}}
507
+
508
+ Next step is to create a new instance of a Datepicker object using the parameters we have set above.
509
+
510
+ {{< code lang="javascript" file="datepicker.js" icon="file" >}}
511
+ import { Datepicker } from 'flowbite';
512
+
513
+ /*
514
+ * $datepickerEl: required
515
+ * options: optional
516
+ */
517
+ const datepicker = new Datepicker($datepickerEl, options, instanceOptions);
518
+ {{< /code >}}
519
+
520
+ Use the following methods to show and hide the datepicker, set or get the currently selected date and get access to the instance.
521
+
522
+ {{< code lang="javascript" file="datepicker.js" icon="file" >}}
523
+ // get the currently selected date (undefined if not selected)
524
+ datepicker.getDate();
525
+
526
+ // set the date (or dates if date range picker)
527
+ datepicker.setDate('05/31/2024');
528
+
529
+ // programatically show the datepicker
530
+ datepicker.show();
531
+
532
+ // programatically hide the datepicker
533
+ datepicker.hide();
534
+
535
+ // use this method to get the parent datepicker instance from https://mymth.github.io/vanillajs-datepicker/#/
536
+ datepicker.getDatepickerInstance();
537
+ {{< /code >}}
538
+
539
+ ### HTML Markup
540
+
541
+ Here is an example of the HTML markup that you can use for the JavaScript example above.
542
+
543
+ {{< code lang="html" file="datepicker.html" icon="file" >}}
544
+ <div class="relative max-w-sm">
545
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
546
+ <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
547
+ <path d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z"/>
548
+ </svg>
549
+ </div>
550
+ <input id="datepicker-custom" type="text" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Select date">
551
+ </div>
552
+ {{< /code >}}
553
+
554
+ ### TypeScript
555
+
556
+ If you're using the <a href="{{< ref "getting-started/typescript" >}}">TypeScript configuration</a> from Flowbite then you can import the types for the Datepicker object, parameters and its options.
557
+
558
+ Here's an example that applies the types from Flowbite to the code above:
559
+
560
+ {{< code lang="typescript" file="datepicker.ts" icon="file" >}}
561
+ import { Datepicker } from 'flowbite';
562
+ import type { DatepickerOptions, DatepickerInterface } from 'flowbite';
563
+ import type { InstanceOptions } from 'flowbite';
564
+
565
+ // set the target element of the input field or div
566
+ const $datepickerEl: HTMLInputElement = document.getElementById('datepicker-custom') as HTMLInputElement;
567
+
568
+ // optional options with default values and callback functions
569
+ const options: DatepickerOptions = {
570
+ defaultDatepickerId: null,
571
+ autohide: false,
572
+ format: 'mm/dd/yyyy',
573
+ maxDate: null,
574
+ minDate: null,
575
+ orientation: 'bottom',
576
+ buttons: false,
577
+ autoSelectToday: 0,
578
+ title: null,
579
+ rangePicker: false,
580
+ onShow: () => {},
581
+ onHide: () => {},
582
+ };
583
+
584
+ // instance options object
585
+ const instanceOptions: InstanceOptions = {
586
+ id: 'datepicker-custom-example',
587
+ override: true
588
+ };
589
+
590
+ /*
591
+ * $datepickerEl: required
592
+ * options: optional
593
+ * instanceOptions: optional
594
+ */
595
+ const datepicker: DatepickerInterface = new Datepicker(
596
+ $datepickerEl,
597
+ options,
598
+ instanceOptions
599
+ );
600
+
601
+ // get the currently selected date (undefined if not selected)
602
+ datepicker.getDate();
603
+
604
+ // set the date (or dates if date range picker)
605
+ datepicker.setDate('05/31/2024');
606
+
607
+ // programatically show the datepicker
608
+ datepicker.show();
609
+
610
+ // programatically hide the datepicker
611
+ datepicker.hide();
612
+
613
+ // use this method to get the parent datepicker instance from https://mymth.github.io/vanillajs-datepicker/#/
614
+ datepicker.getDatepickerInstance();
615
+ {{< /code >}}
616
+
617
+ ### Parent library
618
+
619
+ If you want to directly use the main Datepicker component instance you can either install it via NPM and import it or use the `getDatepickerInstance()` method using our Instance Manager to call all of the extra options and methods from the [parent plugin library](https://github.com/themesberg/flowbite-datepicker):
620
+
621
+ {{< code lang="bash" >}}
622
+ npm install flowbite-datepicker --save
623
+ {{< /code >}}
624
+
625
+ After you've installed the NPM library, you will need to import the `Datepicker` module:
626
+
627
+ {{< code lang="javascript" file="datepicker.js" icon="file" >}}
628
+ import Datepicker from 'flowbite-datepicker';
629
+ {{< /code >}}
630
+
631
+ Initialize a new element using the `Datepicker` constructor and optionally add your own options based on your needs:
632
+
633
+ {{< code lang="javascript" file="datepicker.js" icon="file" >}}
634
+ const datepickerEl = document.getElementById('datepickerId');
635
+ new Datepicker(datepickerEl, {
636
+ // options
637
+ });
638
+ {{< /code >}}
639
+
640
+ If you want to use the **Tailwind Date Range Picker** you have to import the `DateRangePicker` module:
641
+
642
+ {{< code lang="javascript" file="datepicker.js" icon="file" >}}
643
+ import DateRangePicker from 'flowbite-datepicker';
644
+ {{< /code >}}
645
+
646
+ Then in the same fashion you can initialize a date range picker component by using the `DateRangePicker` constructor:
647
+
648
+ {{< code lang="javascript" file="datepicker.js" icon="file" >}}
649
+ const dateRangePickerEl = document.getElementById('dateRangePickerId');
650
+ new DateRangePicker(dateRangePickerEl, {
651
+ // options
652
+ });
653
+ {{< /code >}}
654
+
655
+ ### React support
656
+
657
+ One of our community members built the React version of the Flowbite Datepicker and you can learn more about it on <a href="https://github.com/OMikkel/tailwind-datepicker-react" rel="nofollow">this repository on GitHub</a>.
658
+
659
+ ### Turbo load support
660
+
661
+ In order to support turbo load from Ruby on Rails 7, you have to include the `flowbite.turbo.js` file either from NPM or CDN into your project.
662
+
663
+ Follow the [quickstart guide]({{< ref "getting-started/rails" >}}) and then include the following JavaScript file:
664
+
665
+ {{< code lang="ruby" file="Gemfile" icon="file" >}}
666
+ pin "flowbite", to: "https://cdn.jsdelivr.net/npm/flowbite@{{< current_version >}}/dist/flowbite.turbo.min.js"
667
+ {{< /code >}}
668
+
669
+ Don't forget to also import it inside your `application.js` file:
670
+
671
+ {{< code lang="javascript" file="application.js" icon="file" >}}
672
+ import "flowbite/dist/flowbite.turbo.js";
673
+ {{< /code >}}