Calendar
On this page
phApp.calendar() draws a calendar with month, week, day and list views. Use it for timetables,
bookings, rosters and events. It's FullCalendar 6, styled to match Performance Hub and set up with
the viewer's language and first day of the week.
Add ph-app-calendar.js after ph-app.js on pages with a calendar:
<script defer src="https://app.performancehub.co/assets/app-kit/v1/ph-app-calendar.js"></script>
Week view


Figure 1: A week timetable, with classes coloured by type and an all-day warning
<article class="ph-card">
<header class="ph-card-header">
<div>
<h2 class="ph-card-title">Class timetable</h2>
<p class="ph-card-description">Ormsby Point. Drag a class to move it.</p>
</div>
</header>
<div id="timetable"></div>
</article>
const calendar = phApp.calendar('#timetable', {
initialView: 'timeGridWeek',
editable: true,
events: [
{ title: 'Strength', start: '2026-12-07T09:00', end: '2026-12-07T10:00', tone: 1 },
{ title: 'Yoga', start: '2026-12-07T12:00', end: '2026-12-07T13:00', tone: 2 },
{ title: 'Pool closed', start: '2026-12-10', end: '2026-12-12', allDay: true, tone: 'warning' },
],
eventDrop: async (info) => {
try {
await phApp.fetchJSON(`api/classes/${info.event.id}`, {
method: 'PATCH',
body: { start: info.event.startStr, end: info.event.endStr },
});
} catch {
info.revert();
phApp.toast("Couldn't move the class", { tone: 'error' });
}
},
});
Month view


Figure 2: The month view, with events in status tones
The month view is the default. Busy days show "+2 more" rather than growing.
Event colours
Give each event a tone:
tone | Colour | Use for |
|---|---|---|
1 to 8 | Chart colours 1 to 8 | Categories, such as class types |
'success' | Green | Confirmed, open |
'warning' | Orange | Changed, closures |
'danger' | Red | Cancelled, problems |
'neutral' | Grey | Holidays, background events |
'info' or none | Blue | Everything else |
What the kit sets up
| Option | Kit default |
|---|---|
initialView | 'dayGridMonth' |
| Toolbar | Previous, next and Today on the left; the title in the middle; Month, Week, Day and List on the right |
locale and firstDay | The viewer's language, and its first day of the week |
height | 680px for week and day views; month and list views fit their content |
dayMaxEvents | true ("+2 more" on busy days) |
nowIndicator | true |
scrollTime | 8:00 am |
| Time format | "9:00 am" style |
noEventsText | "Nothing scheduled" |
Pass any other FullCalendar option in the same object, such as
slotMinTime, selectable or eventClick. Your options win over the kit's. phApp.calendar()
returns the FullCalendar Calendar, so use its methods (addEvent, refetchEvents, gotoDate)
directly.
The month, week, day and list views are included. Other FullCalendar plugins, such as resource views, aren't.
React
import { EventCalendar } from 'ph-app-kit-react/calendar';
<EventCalendar initialView="timeGridWeek" events={classes} editable eventDrop={onMove} />
EventCalendar takes the same options as props. Install the FullCalendar packages listed in the
Reference.
Guidelines
- Load events for the range on screen with the
eventsfunction form, not the whole year. - After a drag, save the change and call
info.revert()if the save fails. - Use tones
1to8for categories and the status tones for states; don't mix both meanings in one calendar. - Put the calendar in a card with a title that says whose calendar it is.
Related
- Toasts
- JavaScript API:
fetchJSON