ProtoCalendar
Overview
ProtoCalendar is a self-contained calendar backed by useProtoCalendar. It is built from the
Nuxt UI calendar template (MIT) and provides:
- Three views: day, week, and an infinitely scrolling month (virtualized ±5 years) whose month labels ride the rows as you scroll
- Drag on empty grid to draw a new event; double-click for a one-hour one
- Inline form: clicking an event opens a popover form that saves as you type; right-click for edit / delete
- Move and resize: drag a timed block across days and times (15-minute snap), drag its bottom edge to resize, drag a chip in the month view or the all-day row to another day
- Quick events: type "Lunch with Sam at 1pm tomorrow" into the
+menu; the phrase is parsed in the browser bygpu-time, downloaded on first use - Overlap layout: Google Calendar–style columns for overlapping timed events, lane packing for all-day bars
- External drops: accept HTML5 drag payloads from outside the calendar (e.g. a task panel)
- Y.js CRDT persistence: IndexedDB storage and BroadcastChannel cross-tab sync
Requires @nuxt/ui 4.5 or later.

Click an event to edit it in place:

The week view lays timed events out by the hour, with all-day events in the band above:

Quick Start
<template>
<ProtoCalendar doc-key="my-calendar" class="h-screen" />
</template>
That's it. The component manages its own data layer internally. The calendar fills its container, so give the container a height.
ProtoCalendar Props
| Prop | Type | Default | Description |
|---|---|---|---|
docKey | string | 'proto-calendar' | IDB document key |
namespace | string | — | Optional namespace prefix for multi-tenant isolation |
existingDoc | Y.Doc | — | Pass a shared Y.Doc to co-locate with other tools |
initialView | 'month' | 'week' | 'day' | 'month' | Starting view |
initialDate | string | today | YYYY-MM-DD date to open on |
disableSync | boolean | false | Disable server sync (use local IDB only) |
Every ProtoCalendarView prop and listener below passes through, e.g.
<ProtoCalendar doc-key="cal" :week-starts-on="0" sidebar @event-click="…" />.
ProtoCalendarView — bring your own data
ProtoCalendar is ProtoCalendarView bound to a Y.Doc. Use the view directly to drive the calendar
from anything else: an API, a collection, a store. It owns no persistence: events comes in and every
change goes back out as an emit. A change is shown straight away and held until you hand back a new
events array, so a drop does not snap back while your request is in flight.
<script setup lang="ts">
import type { CalendarViewEvent } from '#protokit/calendar'
const events = ref<CalendarViewEvent[]>([])
function onCreate(event: CalendarViewEvent) {
events.value = [...events.value, event]
}
function onUpdate(event: CalendarViewEvent) {
events.value = events.value.map(e => (e.id === event.id ? event : e))
}
function onRemove(id: string) {
events.value = events.value.filter(e => e.id !== id)
}
</script>
<template>
<ProtoCalendarView
:events="events"
@create="onCreate"
@update="onUpdate"
@remove="onRemove"
/>
</template>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
events | CalendarViewEvent[] | [] | The events to draw |
calendars | CalendarSource[] | [] | Sources events belong to via calendarId; they colour events and fill the sidebar list |
weekStartsOn | 0–6 | 1 | First day of the week (0 = Sunday) |
locale | string | 'en-US' | Locale for day, month and time labels |
views | CalendarView[] | all three | Which views the switcher offers |
editable | boolean | true | Drag to move and resize. Off, the calendar only displays and emits event-click |
creatable | boolean | true | Draw new events on the grid, the + menu and n. Needs editable |
popover | boolean | true | Clicking an editable event opens the inline form. Off, the click is only event-click |
droppable | boolean | false | Accept HTML5 drops from outside (see External Drops) |
loading | boolean | false | Show placeholders where the visible range has no events yet |
toolbar | boolean | true | Title, view switcher, previous / today / next, and the + menu |
sidebar | boolean | false | Mini month and the calendar list, from lg up |
quickEvents | boolean | true | The "Movie at 7pm on Friday" input in the + menu |
shortcuts | boolean | false | t today · d / w / m view · n new · ← / → previous / next. Off by default because they listen page-wide |
Models
| Model | Type | Description |
|---|---|---|
v-model:view | CalendarView | The current view (default 'week'). Bind it when you offer more than one view and want to keep it |
v-model:date | CalendarDate (@internationalized/date) | The date the calendar is on |
v-model:hidden-calendars | string[] | Calendar ids unchecked in the sidebar list |
A prop passed without v-model pins the value: view="month" with :views="['month']" is a month-only calendar.
Emits
| Emit | Payload | When |
|---|---|---|
create | CalendarViewEvent | A drawn or quick event is saved (closing its form saves it; Escape discards it) |
update | CalendarViewEvent | An event is moved, resized, or edited in the form (debounced while typing) |
remove | id: string | Deleted from the form or the right-click menu |
event-click | CalendarViewEvent | Any click on an event, with or without the form |
external-drop | CalendarExternalDrop | Something from outside was dropped on the grid (needs droppable) |
range-change | DateRange | The range on screen changed, and in the month view every 6-week chunk scrolled near; use it to fetch by range |
CalendarViewEvent
interface CalendarViewEvent {
id: string
title: string
start: string // floating local datetime "YYYY-MM-DDTHH:mm:ss"
end: string // exclusive: an all-day event on the 3rd ends at "…-04T00:00:00"
allDay?: boolean
calendarId?: string
color?: CalendarColor // overrides the calendar's colour
description?: string
location?: string
icon?: string // drawn in place of the dot, e.g. "i-lucide-video": says what KIND of thing it is
editable?: boolean // false locks this one event: no drag, no form; clicks still emit
}
Dates are floating local times (no timezone designator): new Date() reads them in the viewer's
own zone, so a 09:15 stand-up is 09:15 wherever it is viewed.
useProtoCalendar Composable
Use the composable directly when you need programmatic control over the stored events.
const {
events, // Ref<CalendarEvent[]> — the stored shape below
addEvent, // (event: Omit<CalendarEvent, 'id'>) => void
updateEvent, // (id: string, patch: Partial<CalendarEvent>) => void
removeEvent, // (id: string) => void
moveEvent, // (id: string, newStartAt: string, newEndAt: string) => void
isReady, // Ref<boolean>
doc, // Y.Doc
} = useProtoCalendar({
docKey: 'my-calendar',
disableSync: false,
})
Options
| Option | Type | Default | Description |
|---|---|---|---|
docKey | string | 'proto-calendar' | IDB document key |
namespace | string | — | Namespace prefix |
existingDoc | Y.Doc | — | Bypass IDB by providing an existing document |
encryption | EncryptionConfig | — | AES-GCM encryption config |
disableSync | boolean | false | Disable server sync |
Stored CalendarEvent type
interface CalendarEvent {
id: string // auto-generated UUID
title: string
startAt: string // local ISO datetime: "YYYY-MM-DDTHH:mm:ss"
endAt: string // for all-day events, the LAST day (inclusive)
allDay: boolean
color: CalendarColor
description: string
location: string
linkedTaskId: string // optional: ID of an external item linked to this event
}
The stored shape predates the view and is kept so existing documents keep opening. Convert between the
two with fromStoredEvent and toStoredPatch from #protokit/calendar, which is what ProtoCalendar
does internally:
import { fromStoredEvent, toStoredPatch } from '#protokit/calendar'
const viewEvents = computed(() => events.value.map(fromStoredEvent))
const onUpdate = (event: CalendarViewEvent) => updateEvent(event.id, toStoredPatch(event))
linkedTaskId is an opaque string your app controls. The calendar stores it but does not interpret it.
Use it to prevent the same external item from being scheduled more than once (see
External Drops below).
Integration with Other Proto Tools
Share a single Y.Doc between a calendar and other tools using existingDoc:

const { doc } = useProtoDoc('shared-workspace')
// Both tools store their data in the same Y.Doc
const calendar = useProtoCalendar({ existingDoc: doc })
const collection = useProtoCollection(schema, { existingDoc: doc })
External Drops
With droppable, the view emits external-drop when an HTML5 drag from outside the calendar lands on
the grid. Where it lands decides the range: an hour at the pointer in the time grid, the whole day on
the all-day row or in the month view.
interface CalendarExternalDrop {
start: string
end: string
allDay: boolean
data: string // application/x-calendar-item, then application/x-task, then text/plain
event: DragEvent
}
<ProtoCalendarView
:events="viewEvents"
droppable
@external-drop="onExternalDrop"
/>
function onExternalDrop({ start, end, allDay, data }: CalendarExternalDrop) {
const task = JSON.parse(data)
addEvent({
...toStoredPatch({ id: '', title: task.title, start, end, allDay, color: task.color ?? 'blue' }),
linkedTaskId: task.id, // prevents the task from being scheduled twice
})
}
To prevent duplicate scheduling, check linkedTaskId before allowing a task to be dragged:
const scheduledTaskIds = computed(() =>
new Set(events.value.map(e => e.linkedTaskId).filter(Boolean))
)
// In template: disable dragging for scheduled tasks
:draggable="!scheduledTaskIds.has(task.id)"
See apps/playground/pages/calendar-tasks.vue for the full example.
Colours
color (or a calendar's colour) takes either a Nuxt UI semantic colour, which follows the app theme:
primary · secondary · success · info · warning · error · neutral
or a Tailwind palette hue:
red · orange · amber · yellow · lime · green · emerald · teal · cyan · sky · blue · indigo · violet · purple · fuchsia · pink · rose
Palette hues are painted from fixed hex values, so they render whether or not the app's Tailwind build
includes that colour. Without calendars, the event form offers a colour picker instead of a calendar
select.
ProtoCrudModal
Modal editor for a single collection item with automatic draft persistence — unsaved changes survive tab switches and browser refreshes.
ProtoItemPanel variants
Specialized panel components for extending a collection item's detail view — text template generation, time-series snapshots, and URL input.