To add a calendar to your page, use the <NuxtCalendar /> component. It works out of the box with sensible defaults.
Copy and paste this snippet into any Vue component to see the calendar in action:
<template>
<div class="h-[600px]">
<NuxtCalendar :events="events" />
</div>
</template>
<script setup lang="ts">
// Events are automatically typed and reactive
const events = ref([
{
id: 1,
title: 'Project Kickoff',
start: new Date(),
end: new Date(Date.now() + 3600000), // 1 hour from now
description: 'Initial meeting with the client'
}
])
</script>
NuxtCalendar component and all related composables are automatically imported by Nuxt.You can switch between 12h and 24h formats in your nuxt.config.ts:
export default defineNuxtConfig({
NuxtCalendar: {
timeFormat: '12h'
}
})
Configure the weekStartsOn option (0 for Sunday, 1 for Monday):
export default defineNuxtConfig({
NuxtCalendar: {
i18n: {
weekStartsOn: 1
}
}
})