Skip to content

Date Selector Component

This component provides a Date Selector Field with AD/BS toggle functionality, allowing users to input dates in both Gregorian (AD) and Nepali (BS) calendars. The component uses Vue DatePicker for AD dates and Nepali DatePicker for BS dates.


Props

Prop NameTypeDefaultDescription
modelValueString""The currently selected AD Date in YYYY-MM-DD format
classValueString""Class for datepicker input fields
isBSBooleanfalseWhether to show the date in BS format by default
showToggleBooleantrueWhether to show the AD/BS toggle button
disabledBooleanfalseWhether the date input is disabled

Emitted Events

Event NamePayloadDescription
update:modelValueStringEmitted when the selected date changes
update:isBSBooleanEmitted when the calendar format is toggled

Example Usage

vue
<template>
  <div>
    <h1>Date Component Examples</h1>
    
    <!-- Basic usage -->
    <DateSelector v-model="date" />
    
    <!-- With custom width -->
    <DateSelector v-model="date" classValue="w-full" />
    
    <!-- Start in BS mode -->
    <DateSelector v-model="date" :isBS="true" />
    
    <!-- Without toggle button -->
    <DateSelector v-model="date" :showToggle="false" />
    
    <!-- Disabled state -->
    <DateSelector v-model="date" :disabled="true" />
  </div>
</template>

<script setup>
import { ref } from 'vue';

const date = ref('2025-04-06');
</script>

Screenshot

Date Selector Component


Notes

  • Ensure the v-model prop is always passed to enable two-way data binding and is always in AD
  • The component always stores and emits dates in AD format (YYYY-MM-DD), even when displaying in BS