Skip to main content

Event calendar Pro

A calendar of events by month, week or day, as Google Calendar and Apple Calendar draw them. Month shows each day's first events and "+N more"; week and day place events by time, side by side when they overlap, with all-day events on top and a red line at now. Step through periods with the arrows, jump to Today, press an event to open it or an empty time (to the half hour) to add one there. Each new period slides in from the side it came from.

import { EventCalendar } from '@patine-ui/pro';
Loading…
<EventCalendar events={events} defaultView="week" onEventPress={(e) => alert(e.title)} onSlotPress={(date) => alert(`New event at ${date.toLocaleString()}`)} style={{ width: '100%' }} />

Try the props​

Props
defaultView
maxEventsPerDay
hourHeight
design
<EventCalendar
events={events}
onEventPress={open}
onSlotPress={create}
defaultView="month"
/>

Example: book a meeting room​

An office's room calendar: the week's bookings for Room Atlas, and pressing a free slot books it for an hour under your name. Bookings can't start in the past.

Loading…
<View style={{ width: '100%', gap: 8 }}>
  <Text weight="semibold">Room Atlas · 8 seats · screen</Text>
  <EventCalendar events={bookings} defaultView="week" views={['week', 'day']} startHour={8} onSlotPress={book} onEventPress={(e) => setNote(`${e.title}, ${e.start.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })}`)} />
  <Text size="sm" color="textSecondary">{note}</Text>
</View>

Views and dates​

view is 'month', 'week' or 'day' (controlled with onViewChange, or defaultView); views picks which the switch offers. date is a day in the period shown (controlled with onDateChange, or defaultDate). In month view "+N more" opens that day, and in week view so does a day's heading.

Loading…
<View style={{ gap: 8, width: '100%' }}>
  <EventCalendar events={shifts} view={view} onViewChange={setView} date={date} onDateChange={setDate} maxEventsPerDay={2} />
  <Text>{`${view} of ${date.toDateString()}`}</Text>
</View>

Time grid​

startHour and endHour (0 and 24) bound the week and day grid, hourHeight (48) sets its scale, height (560) its height, and it opens scrolled to scrollToHour (8). Events shorter than 20 minutes still get room for their title. showNowIndicator={false} drops the now line.

Loading…
<EventCalendar events={appointments} views={['day']} startHour={8} endHour={18} hourHeight={64} height={420} style={{ width: 420 }} />

Your own events​

renderEvent({ event, start, end, time, color, view, theme }) draws an event's content inside its block or pill.

Props​

PropTypeDefaultDescription
eventsCalendarEvent[]—{ id, title, start, end?, allDay?, color?, location?, description?, data? }
view / defaultView / onViewChange'month' | 'week' | 'day''month'
viewsCalendarView[]all threeOne hides the switch.
date / defaultDate / onDateChangeDatetoday
onEventPress(event) => void—
onSlotPress(date, allDay) => void—An empty time or day pressed.
firstDayOfWeek / locale / hour12 / now
startHour / endHour / scrollToHour / hourHeight / heightnumber0 / 24 / 8 / 48 / 560The time grid.
maxEventsPerDaynumber3Month cells.
showHeader / showNowIndicatorbooleantrue
renderEvent(info) => ReactNode—
loading / error / onRetryStates.
density / animate / labels / design / theme / accessibilityLabel / style