Week Calendar
ProNewA week as a grid of hours: events sized by length and set side by side where they overlap, a line at the current time, and slots you press to start an event.
Installation
pnpm dlx shadcn@latest add @viewport/week-calendar
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| days* | { label: string; date: number; today?: boolean }[]The columns, in order. `date` is the day of the month. | — |
| events* | CalendarEvent[] | — |
| from | numberThe first and last hour shown. | 8 |
| to | number | 18 |
| now | numberThe current time as an hour of the day, to draw the line across today. | — |
| onSelect | (id: string) => void | — |
| onCreate | (day: number, start: number) => voidCalled with a day and a start hour when an empty slot is pressed, or a day's add button. | — |
| selected | string | nullThe id of the selected event. | — |
| hourHeight | numberThe height of one hour, in pixels. | 52 |
| className | string | — |
Accessibility
- Events are buttons named with their title, day and times.
- Each day has an add button, so creating does not need a pointer.
- Days keep a readable width and scroll sideways with the hours held in view.
- Opens scrolled to today.
- New events appear without the entrance under reduced motion.