Events data
Event data shapes and callback payloads for @mantine/schedule
Docs
Package
Overview
All @mantine/schedule components accept events through the events prop. Each event
is typed as ScheduleEventData and can be one of three shapes:
- One-off event – a regular event without recurrence
- Recurring series event – a source event that expands into multiple occurrences
- Recurring override event – an event that replaces a single occurrence of a series
All three variants share a common set of base fields described in ScheduleEventBase.
ScheduleEventBase
start and end accept either a Date instance or a string in YYYY-MM-DD HH:mm:ss
format (the DateTimeStringValue type used by all Mantine date components).
ScheduleSingleEventData
A one-off event without recurrence. This is the most common shape:
ScheduleRecurringSeriesEventData
A source event for a recurring series. Adds a recurrence field with an RFC 5545
recurrence rule:
The recurrence object has the following shape:
See the Recurring events guide for more details on recurrence rules and series expansion.
ScheduleRecurringOverrideEventData
An override event replaces a single generated occurrence from a series:
recurringEventId– id of the parent series eventrecurrenceId– original occurrence datetime inYYYY-MM-DD HH:mm:ssformat
EventPayload
Use the payload field to attach your own data to events. It is not used by the library,
you can read it in callbacks and in custom event renderers:
EventPayload is Record<PropertyKey, any>. Pass your own payload type as a generic
argument: ScheduleEventData<MyPayload>.
Recurring instance metadata
Each event generated from a recurring series has a recurringInstance object. It is added
by the library, read it in callbacks and custom renderers to distinguish generated
occurrences from regular events:
Example of reading the metadata in onEventClick:
Callback payloads
onEventClick
Called when an event is clicked in any view:
onEventDrop
Called when an event is dropped after a drag (requires withEventsDragAndDrop):
eventId– id of the dropped event, same asevent.id. For generated recurring occurrences it is the occurrence id ("<seriesId>::<recurrenceId>"), not the series id. Useevent.recurringInstance?.recurringEventIdto get the series id.newStart/newEnd– new datetime values inYYYY-MM-DD HH:mm:ssformat.
onEventResize
Called when an event is resized by dragging its top or bottom edge
(requires withEventResize):
The payload has the same shape as onEventDrop, including the caveat about eventId
for generated recurring instances.
onEventDragStart / onEventDragEnd
Called when an event drag starts or ends:
onEventDragEnd is called both for successful drops and for cancelled drags – use
onEventDrop if you need the new position.
onTimeSlotClick
Called when a time slot is clicked in DayView or WeekView:
slotStart/slotEnd– the slot range inYYYY-MM-DD HH:mm:ssformat. Slot length is controlled by the view'sintervalMinutesprop.
onAllDaySlotClick
Called when the all-day slot is clicked in DayView or WeekView:
date– the clicked date inYYYY-MM-DDformat.
onDayClick
Called when a day is clicked in MonthView or YearView:
date– the clicked date inYYYY-MM-DDformat.
onSlotDragEnd
Called when a slot range is selected by dragging across time slots or day cells
(requires withDragSlotSelect):
rangeStart/rangeEnd– the selected range inYYYY-MM-DD HH:mm:ssformat.
onExternalEventDrop
Called when an item is dragged from outside the schedule and dropped onto a slot:
dataTransfer– the nativeDataTransferobject set by the external item during itsonDragStarthandler. Read your custom data withdataTransfer.getData(type).dropDateTime– the drop target datetime inYYYY-MM-DD HH:mm:ssformat.
Callbacks in resources views
In ResourcesSchedule and Resources* views, onDayClick, onSlotDragEnd and onExternalEventDrop
are called with a single object that includes resourceId of the row. onTimeSlotClick payload
includes resourceId as well:
canDragEvent / canResizeEvent
Permission callbacks – return false to prevent dragging or resizing for a specific event:
preventEventOverlap
Rejects drops and resizes that would make the event overlap another event, see drop validation for what counts as a conflict:
Pass a function to decide per pair of events, return true to forbid the overlap.
movingEvent has the new start and end and, in Resources* views, the target resourceId.
The function is called many times while dragging and resizing, it must be pure and cheap.
canDropEvent / canResizeEventTo / canDropExternalEvent
Placement callbacks – return false to reject a drop or resize based on where the event
is being placed. They are called many times while dragging and again before the placement
is committed, so they must be pure and cheap:
start/end– the candidate range inYYYY-MM-DD HH:mm:ssformat.canDropExternalEventhas noend– the schedule does not know the duration of an external item.resourceId– the target resource, only inResources*views.edge– the edge of the event that is being dragged.dataTransfer– onlydataTransfer.typescan be read while the drag is in progress.
onEventPlacementRejected
Called when a drop, resize or external drop is rejected by preventEventOverlap or by one of
the placement callbacks above. The payload is a discriminated union keyed on action:
conflicts– events the placement collided with, empty when the rejection came from a callback.reason–'overlap'whenpreventEventOverlapfound a conflict,'rejected'when a callback returnedfalse.resourceId– only inResources*views: the target resource fordropandexternal-drop, the event's own resource forresize.
Date and time value formats
Event data and callback payloads use the following string formats consistently:
DateStringValue–YYYY-MM-DD(e.g.2024-01-15)DateTimeStringValue–YYYY-MM-DD HH:mm:ss(e.g.2024-01-15 10:00:00)
These types are shared across @mantine/dates and @mantine/schedule and are exported
from both packages.