npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue3-hijri-gregorian-datepicker

v2.1.0

Published

A Vue 3 date picker component that supports both Hijri and Gregorian calendars

Readme

Vue3 Hijri Gregorian DatePicker

A comprehensive Vue 3 date picker component that seamlessly supports both Hijri (Islamic) and Gregorian calendars with the ability to switch between them on-the-fly.

npm version License: MIT

Features

Dual Calendar Support: Switch seamlessly between Hijri (Islamic) and Gregorian calendars

Time Selection: Optional time picker with hours, minutes, and seconds

🌍 Internationalization: Built-in support for English and Arabic languages

🎨 Theming: Light and dark theme support

📅 Flexible Formatting: Customizable date and time format strings

Accessibility: Keyboard navigation and screen reader support

🎯 Vue 3 Ready: Built with Vue 3 Composition API

📱 Responsive: Works great on mobile and desktop

Installation

npm install vue3-hijri-gregorian-datepicker

Quick Start

<template>
  <div>
    <DatePicker v-model="selectedDate" />
    <p>Selected Date: {{ selectedDate.date }}</p>
    <p>Calendar Type: {{ selectedDate.type }}</p>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import DatePicker from 'vue3-hijri-gregorian-datepicker';
import 'vue3-hijri-gregorian-datepicker/dist/style.css';

const selectedDate = ref({
  date: '22-11-2025',
  type: 'gregorian'
});
</script>

Usage Examples

Basic Gregorian Calendar

<template>
  <DatePicker
    v-model="selectedDate"
    initialType="gregorian"
    language="en"
  />
</template>

<script setup>
import { ref } from 'vue';
import DatePicker from 'vue3-hijri-gregorian-datepicker';
import 'vue3-hijri-gregorian-datepicker/dist/style.css';

const selectedDate = ref({
  date: '',
  type: 'gregorian'
});
</script>

Hijri Calendar with Arabic Language

<template>
  <DatePicker
    v-model="selectedDate"
    initialType="hijri"
    language="ar"
  />
</template>

<script setup>
import { ref } from 'vue';
import DatePicker from 'vue3-hijri-gregorian-datepicker';
import 'vue3-hijri-gregorian-datepicker/dist/style.css';

const selectedDate = ref({
  date: '',
  type: 'hijri'
});
</script>

With Time Picker

<template>
  <DatePicker
    v-model="selectedDate"
    :withTime="true"
    initialType="gregorian"
  />
</template>

<script setup>
import { ref } from 'vue';
import DatePicker from 'vue3-hijri-gregorian-datepicker';
import 'vue3-hijri-gregorian-datepicker/dist/style.css';

const selectedDate = ref({
  date: '',
  type: 'gregorian'
});
</script>

Dark Theme

<template>
  <DatePicker
    v-model="selectedDate"
    :darkTheme="true"
  />
</template>

<script setup>
import { ref } from 'vue';
import DatePicker from 'vue3-hijri-gregorian-datepicker';
import 'vue3-hijri-gregorian-datepicker/dist/style.css';

const selectedDate = ref({
  date: '',
  type: 'gregorian'
});
</script>

Custom Date Format

<template>
  <DatePicker
    v-model="selectedDate"
    format="DD/MM/YYYY"
    initialType="gregorian"
  />
</template>

<script setup>
import { ref } from 'vue';
import DatePicker from 'vue3-hijri-gregorian-datepicker';
import 'vue3-hijri-gregorian-datepicker/dist/style.css';

const selectedDate = ref({
  date: '',
  type: 'gregorian'
});
</script>

Complete Example with All Options

<template>
  <div id="app">
    <!-- Controls -->
    <div class="controls">
      <label>
        <input type="checkbox" v-model="darkTheme" /> Dark Theme
      </label>
      <label>
        <input type="checkbox" v-model="disabled" /> Disabled
      </label>
      <label>
        <input type="checkbox" v-model="withTime" /> With Time
      </label>
      <label>
        <input type="checkbox" v-model="readOnly" /> Read Only
      </label>
      <label>
        Initial Type:
        <select v-model="initialType">
          <option value="gregorian">Gregorian</option>
          <option value="hijri">Hijri</option>
        </select>
      </label>
      <label>
        Language:
        <select v-model="language">
          <option value="en">English</option>
          <option value="ar">Arabic</option>
        </select>
      </label>
    </div>

    <DatePicker
      :initialType="initialType"
      :withTime="withTime"
      v-model="selectedDate"
      :language="language"
      :darkTheme="darkTheme"
      :disabled="disabled"
      :readOnly="readOnly"
      :format="customFormat"
      placeholder="Select a date"
      @cancel="onCancel"
    />

    <!-- Display the selected date and type -->
    <div class="output">
      <p>Selected Date: {{ selectedDate.date }}</p>
      <p>Calendar Type: {{ selectedDate.type }}</p>
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue';
import DatePicker from 'vue3-hijri-gregorian-datepicker';
import 'vue3-hijri-gregorian-datepicker/dist/style.css';

// Reactive state
const darkTheme = ref(false);
const disabled = ref(false);
const withTime = ref(false);
const readOnly = ref(true);
const initialType = ref('gregorian');
const language = ref('en');
const customFormat = ref('');

const selectedDate = ref({
  date: new Date().toISOString().split('T')[0],
  type: initialType.value
});

// Watch initialType and update selectedDate
watch(initialType, (newType) => {
  selectedDate.value = {
    ...selectedDate.value,
    type: newType
  };
});

const onCancel = () => {
  console.log('Date picker cancelled');
};
</script>

<style>
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.output {
  margin-top: 1rem;
  padding: 1rem;
  background-color: #f5f5f5;
  border-radius: 4px;
}
</style>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | modelValue | Object | { date: '', type: 'gregorian' } | The selected date and calendar type | | initialType | String | 'gregorian' | Initial calendar type ('gregorian' or 'hijri') | | withTime | Boolean | false | Enable time selection (hours, minutes, seconds) | | language | String | 'en' | UI language ('en' for English or 'ar' for Arabic) | | format | String | '' | Custom date/time format string (uses moment.js format) | | disabled | Boolean | false | Disable the date picker | | readOnly | Boolean | true | Make the input field read-only | | placeholder | String | 'Select date' | Placeholder text for the input field | | darkTheme | Boolean | false | Enable dark theme |

Events

| Event | Payload | Description | |-------|---------|-------------| | update:modelValue | { date: String, type: String } | Emitted when a date is selected | | cancel | - | Emitted when the picker is closed without selecting |

Date Format Strings

Gregorian Calendar Formats

The component uses moment.js format tokens:

  • DD-MM-YYYY - Day-Month-Year (default)
  • MM/DD/YYYY - Month/Day/Year
  • YYYY-MM-DD - Year-Month-Day (ISO format)
  • DD-MM-YYYY HH:mm:ss - With time
  • YYYY-MM-DD HH:mm:ss - ISO format with time

Hijri Calendar Formats

For Hijri dates, use the i prefix:

  • iDD-iMM-iYYYY - Hijri Day-Month-Year (default)
  • iYYYY/iMM/iDD - Hijri Year/Month/Day
  • iDD-iMM-iYYYY HH:mm:ss - With time

Common Format Tokens

| Token | Output | Description | |-------|--------|-------------| | YYYY | 2025 | 4-digit year | | MM | 01-12 | Month | | DD | 01-31 | Day | | HH | 00-23 | Hours (24-hour) | | mm | 00-59 | Minutes | | ss | 00-59 | Seconds | | iYYYY | 1446 | Hijri year | | iMM | 01-12 | Hijri month | | iDD | 01-30 | Hijri day |

Styling

The component comes with default styles that can be imported:

import 'vue3-hijri-gregorian-datepicker/dist/style.css';

Custom Styling

You can override the default styles using CSS custom properties or by targeting the component classes:

/* Custom theme colors */
.dp__theme_light {
  --dp-primary-color: #1976d2;
  --dp-background-color: #ffffff;
  --dp-text-color: #212121;
}

.dp__theme_dark {
  --dp-primary-color: #90caf9;
  --dp-background-color: #1e1e1e;
  --dp-text-color: #ffffff;
}

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

Dependencies

  • Vue 3.x
  • moment-hijri
  • moment
  • date-fns

Development

# Clone the repository
git clone https://github.com/inaat/vue3-hijri-gregorian-datepicker.git

# Install dependencies
npm install

# Run development server
npm run dev

# Build for production
npm run build

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Inayat Ullah

Links

Acknowledgments

  • Built with Vue 3
  • Uses moment-hijri for Hijri calendar calculations
  • Inspired by the need for dual calendar support in Vue applications

Made with ❤️ for the Vue community