Vue 3 Datepicker

1.1.3 · active · verified Sun Apr 19

Vuejs3-datepicker is a lightweight and configurable datepicker component designed exclusively for Vue 3 applications. Currently at version 1.1.3, the library receives updates approximately every few months, addressing bug fixes, adding new features like internationalization (e.g., Arabic-Tunisia), and internal build system improvements (e.g., Vite migration). Its core functionality includes standard date picking, support for `v-model` for two-way data binding, customizable date formatting, and options for disabling or highlighting specific dates. A key differentiator is its strict compatibility with Vue 3, making it a focused solution for modern Vue projects, unlike some older datepickers that might still support Vue 2.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic Vue 3 setup using the `vuejs3-datepicker` component. It shows importing the component, using `v-model` for two-way binding, custom date formatting, enabling the clear button, setting Monday as the first day of the week, and handling `selected` and `closed` events. It also includes a programmatic way to clear the date.

<template>
  <div id="app">
    <h2>Select a Date</h2>
    <datepicker v-model="selectedDate" :format="'dd MMMM yyyy'"
                :clear-button="true" :monday-first="true"
                @selected="handleDateSelection" @closed="handleCalendarClose">
    </datepicker>
    <p>Selected Date: {{ selectedDate ? selectedDate.toLocaleDateString() : 'None' }}</p>
    <button @click="clearDate">Clear Date</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Datepicker from 'vuejs3-datepicker';

const selectedDate = ref<Date | null>(new Date());

const handleDateSelection = (date: Date) => {
  console.log('Date selected:', date);
  // v-model already updates selectedDate, but you can add other logic here.
};

const handleCalendarClose = () => {
  console.log('Datepicker closed.');
};

const clearDate = () => {
  selectedDate.value = null;
};
</script>

<style>
/* Basic styling for demonstration, replace with your project's styles */
#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 →