✦ A decade of Canvas craft, now driven by AI, describe it, watch it build live.Start building
Bootstrap 5Forms

Bootstrap 5 Date Picker

Bootstrap 5 does not ship a native date picker widget, but you can build one using the HTML5 date input type styled with Bootstrap's form-control class, optionally enhanced with a lightweight JavaScript library such as Flatpickr or Pikaday. Use a date picker any time a user must supply a calendar date, such as booking an appointment, setting a deadline, or filtering records by date range. It replaces free-text date entry, reducing validation errors and improving data consistency.

Primary Class

.date-picker

Common Use Cases

  • Hotel and travel booking forms where guests must select check-in and check-out dates from a calendar overlay
  • Project management dashboards where users set task due dates or milestone deadlines directly on a card or modal
  • Event registration pages that restrict selectable dates to only those on which the event is available, disabling all others
  • HR leave-request forms that highlight weekends and public holidays as non-selectable and enforce a minimum advance-notice period

Variants & Classes

VariantDescription
Date Picker DefaultStandard date picker with Bootstrap's default styling.
Date Picker ResponsiveResponsive variant that adapts to different screen sizes.

Code Example

<div class="mb-3">
  <label for="appointmentDate" class="form-label fw-semibold">Appointment Date</label>
  <input
    type="date"
    class="form-control"
    id="appointmentDate"
    name="appointmentDate"
    min="2025-01-01"
    max="2025-12-31"
    required
  />
  <div class="form-text">Select a date between 1 Jan and 31 Dec 2025.</div>
</div>

<!-- Flatpickr-enhanced version -->
<div class="mb-3">
  <label for="departureDate" class="form-label fw-semibold">Departure Date</label>
  <input
    type="text"
    class="form-control"
    id="departureDate"
    placeholder="DD/MM/YYYY"
    autocomplete="off"
  />
  <div class="form-text">Choose your earliest available departure.</div>
</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" />
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script>
  flatpickr("#departureDate", {
    dateFormat: "d/m/Y",
    minDate: "today",
    disableMobile: true
  });
</script>

Live Examples

Basic Date Picker

Example 1

Canvas Framework Variants

The Canvas template extends Bootstrap 5 with 1,658+ component variants. Generate any of these using Canvas Builder:

  • Canvas Builder generated date picker with custom colours
  • Date Picker with interactive states
  • Responsive date picker for all screen sizes

Best Practices

Always set min and max attributes for bounded date fields

Adding min and max to a date input prevents users from choosing logically impossible values, such as a return date before a departure date, without writing a single line of JavaScript. Pair them with server-side validation because browser constraints can be bypassed.

Override Flatpickr's calendar colours to match your Bootstrap theme

Flatpickr exposes CSS custom properties like --flatpickr-selected-bg, so you can set them to your brand's primary colour with one CSS rule rather than overriding individual selectors. This keeps the calendar visually consistent with your Bootstrap buttons and form controls.

Use disableMobile: true in Flatpickr for a consistent cross-platform UI

On iOS and Android, Flatpickr falls back to the native date picker by default, which looks and behaves differently across devices. Setting disableMobile: true forces your custom calendar on every device, giving a uniform experience at the cost of native keyboard integration.

Pair date inputs with aria-describedby for accessibility

Link your form-text hint to the input using aria-describedby="appointmentDateHelp" so screen readers announce the accepted date range or format immediately after reading the field label, removing ambiguity for keyboard-only users.

FAQ

Does Bootstrap 5 include a built-in date picker component?
No. Bootstrap 5 deliberately excludes a date picker to keep the core library small. The recommended approach is to use the native HTML5 input type='date', which renders the operating system's built-in calendar widget and is fully accessible with zero extra JavaScript. When you need a richer experience, such as date ranges, disabled days, or a consistent cross-browser appearance, add a lightweight third-party library like Flatpickr (around 16 KB gzipped) or Pikaday. Both integrate cleanly with Bootstrap's form-control class.
How do I style a date input or Flatpickr calendar to match my Bootstrap 5 colour scheme?
For the native date input, applying class='form-control' is sufficient to match your form styling in terms of border, padding, border-radius, and focus ring. For Flatpickr, import its base CSS then override the key variables: set .flatpickr-day.selected { background: var(--bs-primary); border-color: var(--bs-primary); } and .flatpickr-day:hover { background: var(--bs-primary-bg-subtle); } in your stylesheet. If you are using Bootstrap 5's CSS custom properties with a custom theme, referencing --bs-primary ensures the calendar automatically adapts when your brand colour changes.
How does Canvas Builder handle Date Picker components?
When you describe a form that requires date selection, Canvas Builder generates the appropriate HTML5 date input wrapped in Bootstrap 5's standard form-group markup, complete with a label, form-control class, and a form-text hint. If your prompt specifies a date range picker or a calendar overlay, Canvas Builder outputs the Flatpickr integration code pre-configured with your project's brand colours mapped to Flatpickr's CSS overrides. The output is fully responsive, using Bootstrap's grid to size the input correctly on mobile and desktop without additional media queries.