A powerful, simple, and customizable Jalali date and time picker for Vue.js and Nuxt applications. This package provides a flexible Jalali calendar component, enabling users to select single dates, date and time, multiple dates, or date ranges with ease. It supports custom theming, slot-based custom inputs, and is optimized for seamless integration into both modern Vue.js and Nuxt projects.
Enhance your Vue.js or Nuxt application with this Vue Jalali date picker for a robust and localized date selection experience, perfect for Persian (Farsi) users or applications requiring Jalali calendar support.
- Single Date Picker: Select a single date using the Jalali calendar.
- Date and Time Picker: Choose both date and time for precise selection.
- Multiple Date Picker: Pick multiple dates effortlessly.
- Date Range Picker: Select a range of dates for flexible use cases.
- Customizable Themes: Customize colors via HSL or specific color values.
- Custom Input Support: Use custom input fields via Vue slots.
- Jalali Calendar Support: Tailored for Persian users with full Jalali date support.
- Nuxt Compatibility: Fully compatible with Nuxt for server-side rendering and static site generation.
Getting started is easy! Choose your preferred package manager and run the following command to add vue-jalali-datetime-picker to your Vue.js or Nuxt project:
# Install with npm (great for Node.js projects)
npm i vue-jalali-datetime-picker
# Install with yarn (if you love speed and simplicity)
yarn add vue-jalali-datetime-picker
# Install with pnpm (perfect for efficient dependency management)
pnpm add vue-jalali-datetime-picker
For quick testing or development without a build step, include the package via a CDN (e.g., unpkg). Add the following script tag to your HTML:
<script src="https://unpkg.com/vue-jalali-datetime-picker@latest/dist/vue-jalali-datetime-picker.umd.js"></script>
Below are examples demonstrating how to use the JalaliDateTimePicker and JalaliMultipleDatePicker components in your Vue.js or Nuxt application. Ensure you import the styles for proper rendering.
-
For Vue Projects: Import the CSS in your component:
<script setup lang="ts"> import "vue-jalali-datetime-picker/style.css"; </script>
-
For Nuxt Projects: Add the CSS to your
nuxt.config.ts
:// nuxt.config.ts export default defineNuxtConfig({ css: ["vue-jalali-datetime-picker/style.css"], });
Import the components into your Vue.js or Nuxt component:
<script setup lang="ts">
import { JalaliDateTimePicker, JalaliMultipleDatePicker } from "vue-jalali-datetime-picker";
</script>
Use the JalaliDateTimePicker for selecting a single date.
<script setup lang="ts">
import { ref } from "vue";
import { JalaliDateTimePicker } from "vue-jalali-datetime-picker";
const selectedDate = ref<Date | null>(null);
</script>
<template>
<JalaliDateTimePicker v-model:date="selectedDate" label="انتخاب تاریخ" />
</template>
Enable time selection by adding the enable-time
prop.
<script setup lang="ts">
import { ref } from "vue";
import { JalaliDateTimePicker } from "vue-jalali-datetime-picker";
const selectedDateAndTime = ref<Date | null>(null);
</script>
<template>
<JalaliDateTimePicker v-model:date="selectedDateAndTime" label="انتخاب تاریخ و زمان" enable-time />
</template>
Use JalaliMultipleDatePicker to select multiple dates.
<script setup lang="ts">
import { ref } from "vue";
import { JalaliMultipleDatePicker } from "vue-jalali-datetime-picker";
const selectedManyDates = ref<Date[]>([]);
</script>
<template>
<JalaliMultipleDatePicker v-model:dates="selectedManyDates" label="انتخاب چندین تاریخ" type="multiple" />
</template>
Select a range of dates using the range
type.
<script setup lang="ts">
import { ref } from "vue";
import { JalaliMultipleDatePicker } from "vue-jalali-datetime-picker";
const selectedPeriodOfDates = ref<Date[]>([]);
</script>
<template>
<JalaliMultipleDatePicker v-model:dates="selectedPeriodOfDates" label="انتخاب بازه ای از تاریخ ها" type="range" />
</template>
You can customize the calendar's appearance in two ways:
Provide HSL values to automatically generate primaryHover
, primaryActive
, and primaryLight
colors.
<script setup lang="ts">
import { ref } from "vue";
import { JalaliDateTimePicker } from "vue-jalali-datetime-picker";
const selectedDate2 = ref<Date | null>(null);
</script>
<template>
<JalaliDateTimePicker
v-model:date="selectedDate2"
label="تقویم با تم کاستوم"
:theme="{
primaryH: '300',
primaryS: '70%',
primaryL: '45%',
textPrimary: 'black',
textSecondary: 'white',
}"
/>
</template>
Set specific color values for full control.
<script setup lang="ts">
import { ref } from "vue";
import { JalaliDateTimePicker } from "vue-jalali-datetime-picker";
const selectedDate2 = ref<Date | null>(null);
</script>
<template>
<JalaliDateTimePicker
v-model:date="selectedDate2"
label="تقویم با تم کاستوم"
:theme="{
primary: '#3b82f6',
primaryHover: '#2563eb',
primaryActive: '#1d4ed8',
primaryLight: '#93c5fd',
}"
/>
</template>
Customize the input field using Vue slots for a tailored user experience.
<script setup lang="ts">
import { ref } from "vue";
import { JalaliDateTimePicker } from "vue-jalali-datetime-picker";
const selectedDate3 = ref<Date | null>(null);
</script>
<template>
<JalaliDateTimePicker v-model:date="selectedDate3" label="انتخاب تاریخ با فیلد کاستوم">
<template #input="{ label, elementId, formattedDate, setShowCalender, clearDate }">
<div>
<label
v-if="label"
:for="elementId"
style="
display: block;
margin-bottom: 6px;
font-size: 14px;
color: #333;
font-weight: 500;
"
>
{{ label }}
</label>
<div
@click="setShowCalender(true)"
style="
display: flex;
align-items: center;
justify-content: space-between;
border: 1px solid #ccc;
border-radius: 6px;
padding: 8px 10px;
font-size: 14px;
color: #333;
background: #fff;
cursor: pointer;
min-height: 36px;
"
>
<span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{{ formattedDate || "—" }}
</span>
<button
v-if="formattedDate"
@click.stop="clearDate"
style="
background: none;
border: none;
color: #888;
cursor: pointer;
padding: 2px 4px;
font-size: 14px;
"
>
❌
</button>
</div>
</div>
</template>
</JalaliDateTimePicker>
</template>
If you encounter any bugs or have suggestions for improvements, please share them in the GitHub Issues section of our repository. We welcome your feedback to make this Vue Jalali date picker even better!
- Vue.js - The Progressive JavaScript Framework
- jalaali-js - A library for working with Jalali (Persian) calendar dates
This project is licensed under the MIT License.