Vue Datepicker UI

2.3.0 · active · verified Sun Apr 19

Vue Datepicker UI is an open-source, lightweight datepicker component designed for seamless integration into Vue.js applications. It currently supports both Vue 2 (versions 2.x, with 2.3.0 being the latest minor release) and Vue 3 (versions 3.x, with 3.1.1 being the latest minor release, accessible via the `@vue3` npm tag). The library maintains a moderate release cadence, providing minor feature enhancements and bug fixes, as seen with recent updates like 2.3.0 and 3.1.1 which added a `reset` event and `showPickerInital` property respectively. A key differentiator is its modularity; style files are optional, allowing developers to completely customize the component's appearance or integrate it into existing design systems without conflicts. Furthermore, it boasts a smaller bundle size since version 2.0.0, contributing to improved application performance. The component provides essential date selection functionalities, including single and multi-picker modes, with features like a clear date button for enhanced user experience.

Common errors

Warnings

Install

Imports

Quickstart

This Vue 2.x example demonstrates importing, registering, and using the `Datepicker` component for single date and date range selection with `v-model` and a clear button. It also includes the necessary CSS import.

<template>
  <div id="app">
    <h1>Select a Date</h1>
    <Datepicker v-model="selectedDate" :clear-button="true" date-format="DD.MM.YYYY"></Datepicker>
    <p>Selected Date: {{ selectedDate ? new Date(selectedDate).toLocaleDateString() : 'None' }}</p>

    <h2>Date Range Selection</h2>
    <Datepicker v-model="dateRange" range></Datepicker>
    <p>Range: {{ dateRange && dateRange.from && dateRange.to ? `${new Date(dateRange.from).toLocaleDateString()} - ${new Date(dateRange.to).toLocaleDateString()}` : 'None' }}</p>
  </div>
</template>

<script>
import Datepicker from 'vue-datepicker-ui';
import 'vue-datepicker-ui/lib/vuedatepickerui.css';

export default {
  name: 'App',
  components: {
    Datepicker
  },
  data() {
    return {
      selectedDate: null,
      dateRange: { from: null, to: null }
    };
  },
  mounted() {
    // Example: Set initial date to today
    this.selectedDate = new Date();
  }
};
</script>

<style>
/* Optional: Add some basic styling or overrides */
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

view raw JSON →