Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1 class="mb-4">Vanilla Datepicker for Bootstrap 5</h1>

<h2>Floating label only</h2>

<div class="form-floating mb-4 d-flex">
         class="datepicker_input form-control border-2"
  <label for="datepicker1">Date input label 1</label>

<h2>Input group only</h2>

<div class="input-group mb-4">
  <i class="bi bi-calendar-date input-group-text"></i>
  <input type="text" class="datepicker_input form-control" placeholder="Date input 3 placeholder" required aria-label="Date input 3 (using aria-label)">

<h2>Floating label &amp; input group</h2>

<div class="form-floating input-group mb-4">
  <i class="bi bi-calendar-date input-group-text"></i>
  <input type="text" id="datepicker2" class="datepicker_input form-control" placeholder="DD/MM/YYYY" required>
  <label for="datepicker2">Date input label 2</label>

<p>Requires <a target=_blank title="[new window]" href="">vanillajs-datepicker</a> plus the usual Bootstrap 5 CSS &amp; JS.</p>

<!-- Footer include -->


                /* Bootstrap 5 CSS and icons included */
/* vanillajs-datepicker 1.1.4 CSS included */

body {
  /* Centring content */
  min-height: 100vh;
  display: grid;
  place-content: center;

/* Adapts a floating label for use with a left-handed input group icon */
.form-floating > .bi-calendar-date + .datepicker_input + label {
  padding-left: 3.5rem;
  z-index: 3;


                /* Bootstrap 5 JS included */
/* vanillajs-datepicker 1.1.4 JS included */

const getDatePickerTitle = elem => {
  // From the label or the aria-label
  const label = elem.nextElementSibling;
  let titleText = '';
  if (label && label.tagName === 'LABEL') {
    titleText = label.textContent;
  } else {
    titleText = elem.getAttribute('aria-label') || '';
  return titleText;

const elems = document.querySelectorAll('.datepicker_input');
for (const elem of elems) {
  const datepicker = new Datepicker(elem, {
    'format': 'dd/mm/yyyy', // UK format
    title: getDatePickerTitle(elem)