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';
<EventCalendar events={events} defaultView="week" onEventPress={(e) => alert(e.title)} onSlotPress={(date) => alert(`New event at ${date.toLocaleString()}`)} style={{ width: '100%' }} />
Try the props
defaultViewmaxEventsPerDayhourHeightdesign<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.
<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.
<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.
<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
| Prop | Type | Default | Description |
|---|---|---|---|
events | CalendarEvent[] | — | { id, title, start, end?, allDay?, color?, location?, description?, data? } |
view / defaultView / onViewChange | 'month' | 'week' | 'day' | 'month' | |
views | CalendarView[] | all three | One hides the switch. |
date / defaultDate / onDateChange | Date | today | |
onEventPress | (event) => void | — | |
onSlotPress | (date, allDay) => void | — | An empty time or day pressed. |
firstDayOfWeek / locale / hour12 / now | |||
startHour / endHour / scrollToHour / hourHeight / height | number | 0 / 24 / 8 / 48 / 560 | The time grid. |
maxEventsPerDay | number | 3 | Month cells. |
showHeader / showNowIndicator | boolean | true | |
renderEvent | (info) => ReactNode | — | |
loading / error / onRetry | States. | ||
density / animate / labels / design / theme / accessibilityLabel / style |