Skip to content
On this page

Calendar

Sub-component for Datepicker

Usage

Simple Usage

preview
vue
<template>
  <p-calendar />
</template>

Limiting Date

You can limit the date via min or max props

preview
vue
<template>
  <!-- Limit 1 Jan - 31 Dec 2022 -->
  <p-calendar
    :min="new Date(2022, 0, 1)"
    :max="new Date(2022, 11, 31)" />
</template>

Mode Variant

There 3 available mode: date , month, year. default is date. it will limit user input the date.

for example, mode month make user can only select the month, but can't select what spesific date.

preview
vue
<template>
  <p-calendar
    mode="date" />
  <p-calendar
    mode="month" />
  <p-calendar
    mode="year" />
</template>

Disabled State

preview
vue
<template>
  <p-calendar disabled />
</template>

Readonly state

preview
vue
<template>
  <p-calendar readonly />
</template>

Binding v-model

preview
vue
<template>
  <p-calendar v-vmodel="value" />
</template>

Result :

-

Example:

Result:
preview
vue
<template>
  <div>
    <p-calendar v-model="value" />
    <div>
      Result: {{ value && format(value, 'dd-MM-yyyy') }}
    </div>
  </div>
</template>

<script setup>
  import { format } from 'date-fns'
</script>

API

Props

PropsTypeDefaultDescription
modelValueDate-v-model value
disabledBooleanfalseDisabled state
readonlyBooleanfalseReadonly state
modeString-Calendar mode valid value: date, month, year
maxDate-Maximum date can be selected
minDate-Minimum date can be selected

Slots

NameDescription
There no slots here

Events

NameArgumentsDescription
changeNative Date objectEvent when date selected

See Also

Released under the MIT License.