Components
Time Grid
The scrollable hour grid behind the day and week views.
The time grid lays out days as columns and hours as rows. Day View and Week View are both built on it, and you can use it directly for a custom layout.
Installation
pnpm dlx shadcn add @calendarcn/time-gridFeatures
- A time axis, a column per day and a current-time indicator.
- An all-day row for all-day and multi-day events.
- Overlapping events placed side by side.
- Drag an event to move it, including to another day. The grid scrolls when you reach its edge.
- Drag the top or bottom edge of an event to resize it.
- Double-click an empty slot to create an event, or press and drag to draw one, as in Notion Calendar. The all-day row does the same for all-day events. See Creating events.
- Visible hours, snap step and clock come from
CalendarProvider:dayStartHour,dayEndHour,snapMinutesandhourCycle. - Additional time zones' hours beside the time axis, from the provider's
secondaryTimeZones. Each zone's label opens Notion Calendar's menu for it (change, make primary or secondary, remove), and the "+" left of "All-day" adds one. - The calendar's own zone,
timeZone, labels the time axis, and a zone travelled to is filled in the primary color with an x that travels back home. - The provider's view settings: with weekends hidden the columns are weekdays only, so scrolling, previous and next, and a drag from Friday to the next column all step over the weekend to Monday. Declined events are struck through on a dashed outline, or hidden.
- Other people's events behind yours, hatched in their color, and the free time you share highlighted, while you meet with them or show their calendar: see Meeting with people.
- Hours that fill the screen by default, or the provider's
hourHeight, which zooming steps through while the middle of the screen stays put.
Usage
import { CalendarProvider } from "@/components/calendar-provider";
import { TimeGrid } from "@/components/time-grid";
export function ThreeDays() {
return (
<CalendarProvider defaultEvents={events}>
<div className="h-[600px]">
<TimeGrid view="week" numberOfDays={3} />
</div>
</CalendarProvider>
);
}API Reference
TimeGrid
Use it directly when you switch between day and week yourself and want to keep the scroll position, as the demo does. Everything else is set on CalendarProvider.
| Prop | Type | Default |
|---|---|---|
view (required)"day" shows one column, "week" shows numberOfDays columns. While the provider's view is uncontrolled, the provider adopts it, so navigation and header info follow it. | "day" | "week" | – |
numberOfDaysNumber of day columns. Defaults to the provider's numberOfDays. When set, it fixes the column count, and prev/next step by it below 7 while the provider's numberOfDays is uncontrolled. | number | – |
showEventPopoverWhether the selected event opens a details popover beside it. Turn it off when the details are shown elsewhere, such as a side panel. | boolean | true |
onEventPopoverExpandCalled by the popover's expand button, e.g. to move the details into a side panel. The button is hidden when this is not set. | () => void | – |
scrollToHourHour the grid scrolls to when it mounts, e.g. 8 for 8 AM or 8.5 for 8:30. Applied once and clamped to the provider's dayStartHour..dayEndHour. Unset starts at the top. | number | – |
classNameClasses for the root element. | string | – |