Skip to content

Calendar

A pixel-art styled calendar component for selecting dates with month navigation, keyboard support, and full i18n.

NameCategoryDescriptionTypeDefault
type? StyleColor type'primary' | 'success' | 'info' | 'warning' | 'danger'
color? ColorCustom hex colorstring
modelValue / v-model? StateCurrently selected dateDate
defaultMonth? StateInitial displayed monthDate
minDate? StateMinimum selectable dateDate
maxDate? StateMaximum selectable dateDate
disabledDate? BehaviorFunction to determine if a date is disabled(date: Date) => boolean
showOutsideDays? BehaviorShow dates outside the current monthbooleantrue
weekStartsOn? BehaviorWeek start day (0=Sunday, 1=Monday)0 | 10
yearRange? BehaviorYear range for the year dropdown [startYear, endYear][number, number][currentYear - 10, currentYear + 10]
update:modelValue? EventTriggered when selected date changes(date: Date) => void
month-change? EventTriggered when the displayed month changes(date: Date) => void
focus? ExposeFocus the calendar() => void
prevMonth? ExposeNavigate to previous month() => void
nextMonth? ExposeNavigate to next month() => void

Basic Usage

Use v-model to bind the selected date. The calendar displays the current month by default.

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

const date = ref<Date>();
</script>

<template>
  <div class="demo-calendar">
    <px-calendar v-model="date" />
    <p v-if="date">Selected: {{ date.toLocaleDateString() }}</p>
  </div>
</template>

<style scoped>
.demo-calendar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}
</style>

Types

Use type property to set the calendar color theme.

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

const date = ref<Date>();
</script>

<template>
  <div class="demo-calendar-types">
    <px-calendar v-model="date" type="primary" />
    <px-calendar v-model="date" type="success" />
    <px-calendar v-model="date" type="warning" />
    <px-calendar v-model="date" type="danger" />
    <px-calendar v-model="date" type="info" />
  </div>
</template>

<style scoped>
.demo-calendar-types {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
</style>

Disabled Dates

Use disabledDate function or minDate/maxDate to restrict selectable dates.

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

const date = ref<Date>();

const isWeekend = (d: Date) => d.getDay() === 0 || d.getDay() === 6;

const today = new Date();
const minDate = new Date(today.getFullYear(), today.getMonth(), 1);
const maxDate = new Date(today.getFullYear(), today.getMonth() + 1, 0);
</script>

<template>
  <div class="demo-calendar-disabled">
    <div>
      <p>Disable weekends:</p>
      <px-calendar v-model="date" :disabled-date="isWeekend" />
    </div>
    <div>
      <p>Date range (current month only):</p>
      <px-calendar v-model="date" :min-date="minDate" :max-date="maxDate" />
    </div>
  </div>
</template>

<style scoped>
.demo-calendar-disabled {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}
</style>

Custom Color

Use color property to set a custom hex color for selection and today highlights.

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

const date = ref<Date>();
</script>

<template>
  <div class="demo-calendar-color">
    <px-calendar v-model="date" color="#e64553" />
    <px-calendar v-model="date" color="#8839ef" />
    <px-calendar v-model="date" color="#40a02b" />
  </div>
</template>

<style scoped>
.demo-calendar-color {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
</style>