Schedule

A calendar of events, by day, week or month. Events sit on a grid of hours, side by side when they overlap, and all-day events have a row of their own. Use it for appointments, shifts, bookings and meetings.

General

Pass events with a start and an end. The header changes the date and the view.

Month

Past maxEventsPerDay, a day shows a +N more button that opens that day.

Create and open events

With onSlotClick, each hour is a button that reports its start and end. onEventClick reports the event.

APIs

Schedule.Props

AttributeDescriptionTypeAccepted valuesDefault
eventswhat to showScheduleEvent[]ScheduleEvent[]
viewthe view, to control itstring'day', 'week', 'month'-
initialViewthe view at the startstring'day', 'week', 'month'week
onViewChangecalled with the new view(view: ScheduleView) => void--
datea day of the period shown, to control itDate--
initialDatea day of the period at the startDate-today
onDateChangecalled with the new day(date: Date) => void--
viewsthe views offered in the headerScheduleView[]-all three
localelanguage of the dates and the timesstring-en-US
weekStartsOnday that starts a week, 0 is Sundaynumber0 to 60
startHourfirst hour of the gridnumber-0
endHourhour where the grid endsnumber-24
slotHeightheight of an hour, in pixelsnumber-48
intervalMinuteslength of a slot that can be clickednumber-60
heightheight of the grid, in pixelsnumber-600
startScrollHourhour the grid is scrolled tonumber-7
maxEventsPerDayevents shown in a month day before +N morenumber-3
withCurrentTimeIndicatordraw a line at the current timeboolean-true
getNowwhere the current time comes from() => Date-the clock
labelstexts of the header and the buttonsPartial<ScheduleLabels>ScheduleLabelsEnglish
onEventClickcalled when an event is clicked(event: ScheduleEvent) => void--
onSlotClickcalled with the start and the end of a slot, and turns the slots into buttons(start: Date, end: Date) => void--
onDayClickcalled when a day number is clicked, which also opens that day(date: Date) => void--
...native props, passed to the rootHTMLAttributes'aria-label', 'className', ...-

ScheduleEvent

type ScheduleEvent = {
  id: string | number
  title: string
  start: Date
  end: Date
  color?: string // any CSS color, the theme primary when missing
  allDay?: boolean // events of a day or more also go to the all-day row
  payload?: unknown // your own data
}

ScheduleLabels

type ScheduleLabels = {
  today: string
  previous: string
  next: string
  view: string
  day: string
  week: string
  month: string
  allDay: string
  more: (count: number) => string
}

Ref

The ref points at the root div.

Accessibility

The header buttons and the views are real buttons, and the view that is on has aria-pressed. Each day of the grid is a group named by its date, and each event is a button named by its title and time.

With onSlotClick, the slots are one tab stop, moved with the arrow keys: Up and Down between hours, Left and Right between days, Home and End to the first and last hour. In the month view the day numbers work the same way, and Home and End go to the start and end of the week.

Dragging and resizing events are not part of this component.

Edit this page on GitHub