API Documentation

Calendar props

NameDescription
calendarCalendar object returned by the useEventsCalendar hook
compactRenders a more compact calendar
enableDragCreationEnables drag event creation
eventsMain array containing events to display in the calendar
isFetchingActivates a loading overlay. Useful for asynchronous data fetching
noHeaderRemoves the default calendar header
onEventClickEvent click handler
onEventCreateEvent creation handler. Fires after event drag creation. Requires enableDragCreation
renderPopoverRender function for popovers bound to a calendar event. Used with onEventClick and onEventCreate to display events within a popover.
renderContextMenuRender function for a context menu bound to a calendar event. Used with onEventClick and onEventCreate to bind actions to an event.
viewsA subset of the array ['year', 'month', 'week', 'day']. Determines the view control in the default header

Calendar prop types

export interface EventsCalendarProps<T extends RawCalendarEventBase = RawCalendarEventBase> {
    calendar?: EventsCalendarObject;
    compact?: boolean;
    enableDragCreation?: boolean;
    events?: RawCalendarEvent<T>[];
    isFetching?: boolean;
    noHeader?: boolean;
    popoverZIndex?: number;
    views?: CalendarView[];
    onEventClick?: (props: EventClickArgs<T>) => void;
    onEventCreate?: (props: EventEditProps) => void;
    onEventReschedule?: (props: EventEditProps) => void;
    renderPopover?: (props: EventsCalendarPopoverProps) => ReactNode;
    renderContextMenu?: (props: EventsCalendarContextMenuProps) => ReactNode;
}

Calendar event object

export type RawCalendarEvent = {
  id?: number | null;
  title?: string;
  start?: string | number | Date | Dayjs;
  end?: string | number | Date | Dayjs;
  startTime?: string | null;
  endTime?: string | null;
  isAllDay?: boolean;
  groups?: { label: string; color: string }[];
}

The useEventsCalendar hook

With the useEventsCalendar hook, you can set the initial state of the calendar, as well as manage the calendar state externally. A common use-case is for creating custom header elements.

export type useEventsCalendarProps {
    initialDate?: string | number | Date | Dayjs;
    initialView?: CalendarView;
}
const calendar = useEventsCalendar({ initialDate: '01-Aug-2024', initialView: 'week' })

The hook returns a object containing the following properties:

export type EventsCalendarObject = {
    activeDate: dayjs.Dayjs;
    setActiveDate: Dispatch<SetStateAction<dayjs.Dayjs>>;
    view: CalendarView;
    setView: Dispatch<SetStateAction<CalendarView>>;
};

On this page