ChronousDocumentation

Examples

Week view

A full week with an all-day strip, a time grid, a now marker and a toolbar.

A week

A week with a toolbar, day headings, an all-day strip that never collapses, a time grid scrolled to eight in the morning and a recurring standup. Use the controls above to step through the range. The preview shows the same layout model described in the guide.

Running here

The component

Nothing here positions anything: the grid columns, the height of a box and the lane of a bar all arrive as inline styles. What is left is colour, borders and type.

Week.tsx
'use client'

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

type EventData = { title: string }

const Calendar = createCalendarComponents<EventData>()

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

const EVENTS: EventInput<EventData>[] = [
  {
    id: 'offsite',
    start: '2026-03-18',
    end: '2026-03-20',
    data: { title: 'Offsite' },
  },
  {
    id: 'standup',
    start: '2026-03-16T09:00',
    duration: 'PT15M',
    recurrence: { rule: 'FREQ=WEEKLY;BYDAY=MO,WE,FR' },
    data: { title: 'Standup' },
  },
  {
    id: 'review',
    start: '2026-03-18T14:00',
    end: '2026-03-18T15:30',
    data: { title: 'Design review' },
  },
  {
    id: 'pairing',
    start: '2026-03-18T14:30',
    end: '2026-03-18T16:00',
    data: { title: 'Pairing' },
  },
]

export const Week = (): JSX.Element => {
  const [range, setRange] = useState<CalendarRange>(INITIAL)

  return (
    <Calendar.Root
      className="flex flex-col min-w-160 h-160 text-slate-200 bg-slate-950 border border-white/15 rounded-xl overflow-hidden"
      range={range}
      events={EVENTS}
      locale="en-GB"
      gutterWidth="56px"
    >
      <Calendar.Toolbar
        className="flex items-center gap-3 px-3 py-2.5"
        onNavigate={setRange}
      >
        {({ title, navigation, goTo }) => (
          <>
            <button
              type="button"
              className="text-inherit bg-transparent border-0 cursor-pointer m-0 p-0"
              disabled={!navigation.prev}
              onClick={() => navigation.prev && goTo(navigation.prev)}
            >
              ←
            </button>
            <strong>{title}</strong>
            <button
              type="button"
              className="text-inherit bg-transparent border-0 cursor-pointer m-0 p-0"
              disabled={!navigation.next}
              onClick={() => navigation.next && goTo(navigation.next)}
            >
              →
            </button>
          </>
        )}
      </Calendar.Toolbar>

      <Calendar.Header className="border-b border-white/15">
        <Calendar.DayHeadings className="py-2 text-center text-sm leading-5 border-l border-white/5">
          {({ weekdayLabel, dayLabel }) => (
            <>
              <span>{weekdayLabel}</span> <strong>{dayLabel}</strong>
            </>
          )}
        </Calendar.DayHeadings>
      </Calendar.Header>

      <Calendar.AllDayRow
        className="py-1 bg-white/5 border-b border-white/15"
        minLanes={1}
        gutterCell={
          <span className="block pr-2 text-slate-400 text-xs leading-6 text-right">
            all-day
          </span>
        }
      >
        <Calendar.AllDayEvents className="px-1.5 text-xs leading-6 text-left text-slate-950 bg-blue-300 rounded-md overflow-hidden truncate border-0">
          {({ event }) => event.data?.title}
        </Calendar.AllDayEvents>
      </Calendar.AllDayRow>

      <Calendar.TimeGrid
        className="flex-1 pt-2.5"
        hourHeight={48}
        scrollToHour={8}
      >
        <Calendar.TimeAxis>
          <Calendar.TimeLabels className="right-2 text-xs text-slate-400" />
        </Calendar.TimeAxis>

        <Calendar.DayColumns className="border-l border-white/5">
          <Calendar.TimeSlots className="border-t border-white/5" />
          <Calendar.NowMarker className="border-t-2 border-orange-400" />
          <Calendar.TimedEvents
            as="button"
            className="m-0 px-1.5 py-1 text-xs leading-4 text-left text-slate-950 bg-violet-400 rounded-md overflow-hidden cursor-pointer border-0"
          >
            {({ event, box }) => (
              <span className="block font-semibold line-clamp-3 break-words">
                {event.data?.title}
                {box.continuesAfter && ' ↓'}
              </span>
            )}
          </Calendar.TimedEvents>
        </Calendar.DayColumns>
      </Calendar.TimeGrid>
    </Calendar.Root>
  )
}

Worth noting

  • gutterWidth sits on the root because the header, the all-day row and the grid share one column template.
  • minLanes of 1 holds the all-day strip open on weeks that have no all-day event, so the grid below it does not jump as you step. Try the arrows above.
  • as="button" makes each event a real button — focusable, and keyboard-operable — without changing anything else.
  • The standup is one event with a rule, expanded only for the week on screen. See Recurrence.
  • NowMarker draws only in the column that is today, so it stays hidden while the range is anchored on March 2026.