Vue Guide
Vue Guide
@thaparoyal/calendar-vue provides headless composables for building calendar UIs in Vue 3. Instead of pre-built components, you get reactive state and actions — you bring your own template and styling.
Installation
npm install @thaparoyal/calendar-vue @thaparoyal/calendar-coreImport the theme CSS in your app entry or component:
import '@thaparoyal/calendar-core/themes/themes.css';Composables
| Composable | Purpose |
|---|---|
useCalendar | Single calendar with month/year pickers |
useSelection | Unified selection: single, range, or multiple |
useDatePicker | Calendar inside a popup with input field |
useMultiCalendar | Multiple months displayed side by side |
Headless Pattern
Every composable returns reactive computed refs and an actions object. You wire them into your own <template>:
<script setup lang="ts">import { useCalendar } from '@thaparoyal/calendar-vue';import '@thaparoyal/calendar-core/themes/themes.css';
const { weeks, title, weekdayNames, actions, formatDayNumber, isPrevMonthDisabled, isNextMonthDisabled } = useCalendar({ config: { calendarType: 'BS', locale: 'en' },});</script>
<template> <div class="trc-calendar" data-theme="default"> <div class="trc-calendar-header"> <button class="trc-calendar-nav-button" @click="actions.prevMonth()" :disabled="isPrevMonthDisabled">‹</button> <span class="trc-calendar-title">{{ title }}</span> <button class="trc-calendar-nav-button" @click="actions.nextMonth()" :disabled="isNextMonthDisabled">›</button> </div> <table class="trc-calendar-grid"> <thead class="trc-calendar-grid-head"> <tr> <th v-for="day in weekdayNames" :key="day" class="trc-calendar-weekday">{{ day }}</th> </tr> </thead> <tbody> <tr v-for="(week, wi) in weeks" :key="wi" class="trc-calendar-week"> <td v-for="d in week" :key="`${d.date.year}-${d.date.month}-${d.date.day}`" class="trc-calendar-cell" :class="{ 'trc-calendar-cell-today': d.isToday, 'trc-calendar-cell-selected': d.isSelected, 'trc-calendar-cell-outside': d.isOutsideMonth, 'trc-calendar-cell-disabled': d.isDisabled, }" > <button class="trc-calendar-day" :disabled="d.isDisabled || d.isOutsideMonth" @click="actions.selectDate(d.date)" >{{ formatDayNumber(d.date.day) }}</button> </td> </tr> </tbody> </table> </div></template>The trc-* CSS classes come from the core theme stylesheet, so your calendar automatically picks up whichever theme you set via data-theme.
Themes
Apply any of the 12 built-in themes with the data-theme attribute:
default | ocean | forest | sunset | lavender | midnight | rose | mint | amber | slate | coral | indigo
<div class="trc-calendar" data-theme="ocean"> <!-- calendar content --></div>Next Steps
- Calendar (useCalendar) — BS/AD, month picker, year picker, Nepali locale
- Range Selection (useSelection) — date range and multi-date selection
- Multi-Calendar (useMultiCalendar) — side-by-side months
- Date Picker (useDatePicker) — input + dropdown calendar
- All Examples — interactive demo of every feature