ChronousDocumentation

Examples

Month view

A month grid with weekday headings, capped lanes and a “+2 more” affordance.

A month

A month grid with weekday headings, three lanes of all-day bars per week and a “+1 more” button on the days where something did not fit. Extra overlapping all-day events demonstrate the lane limit.

Running here

The component

Month.tsx
import { createCalendarComponents } from '@midstem/chronous-react'
import type { CalendarRange, EventInput } from '@midstem/chronous-react'

type EventData = { title: string }

const Calendar = createCalendarComponents<EventData>()

const LANE_HEIGHT = 26

const RANGE: CalendarRange = {
  view: 'month',
  currentDate: '2026-03-18',
  timeZone: 'Europe/Kyiv',
}

const EVENTS: EventInput<EventData>[] = [
  {
    id: 'offsite',
    start: '2026-03-16',
    end: '2026-03-20',
    data: { title: 'Offsite' },
  },
  {
    id: 'freeze',
    start: '2026-03-17',
    end: '2026-03-19',
    data: { title: 'Code freeze' },
  },
  {
    id: 'audit',
    start: '2026-03-17',
    end: '2026-03-21',
    data: { title: 'Security audit' },
  },
  {
    id: 'retro',
    start: '2026-03-18',
    end: '2026-03-19',
    data: { title: 'Retro' },
  },
  {
    id: 'review',
    start: '2026-03-18T14:00',
    end: '2026-03-18T15:30',
    data: { title: 'Design review' },
  },
]

export const Month = (): JSX.Element => (
  <Calendar.Root
    className="min-w-176 text-slate-200"
    range={RANGE}
    events={EVENTS}
    locale="en-GB"
  >
    <Calendar.MonthGrid className="flex flex-col">
      {/* MonthGrid is a flex column, so the weekday row brings its own grid */}
      <div className="grid grid-cols-7">
        <Calendar.MonthWeekdays className="py-2 text-center text-xs text-slate-400" />
      </div>

      <Calendar.MonthRows
        className="grid grid-cols-7 border-t border-white/15"
        maxLanes={3}
        laneHeight={LANE_HEIGHT}
      >
        <Calendar.MonthDays className="relative min-w-0 min-h-32 p-1 border-l border-white/5">
          {({ dayLabel, lanes, hiddenBars }) => (
            <>
              <span className="block h-7 text-center text-xs leading-7">
                {dayLabel}
              </span>

              {/* the bars float above the cells, so reserve their height */}
              <div style={{ height: lanes * LANE_HEIGHT }} />

              <Calendar.MonthTimedEvents className="block box-border w-full min-w-0 mt-1 px-1.5 text-xs leading-5 text-slate-950 bg-violet-400 rounded truncate">
                {({ event }) => (
                  <span title={event.data?.title}>{event.data?.title}</span>
                )}
              </Calendar.MonthTimedEvents>

              {hiddenBars.length > 0 && (
                <button
                  className="m-0 mt-1 p-0 text-xs leading-4 text-slate-400 bg-transparent border-0 cursor-pointer"
                  type="button"
                >
                  +{hiddenBars.length} more
                </button>
              )}
            </>
          )}
        </Calendar.MonthDays>

        <Calendar.MonthAllDayEvents className="box-border px-1.5 text-xs leading-5 text-slate-950 bg-blue-300 rounded truncate border-t-2 border-transparent bg-clip-padding">
          {({ event }) => event.data?.title}
        </Calendar.MonthAllDayEvents>
      </Calendar.MonthRows>
    </Calendar.MonthGrid>
  </Calendar.Root>
)

The spacer

The bars of a week float above the cells, so each cell reserves room for them with lanes * LANE_HEIGHT — where lanes counts only what was actually drawn. Everything below that spacer, timed events included, then flows underneath the bars instead of behind them. Layout & lanes explains where those numbers come from.