React Event calendar Property Reservations

When keeping records of bookings, the event calendar with exact label displays can come in handy. The labels accurately mark the exact start (e.g. 14:00) and end times (e.g. 11:00) of bookings, consolidating all booking records in a single, clear view.

By combining the eventDisplay: 'exact' setting under the view option with customizable renderCalendarEventContent , you can tailor the calendar to your specific needs. This allows you to create an efficient and user-friendly booking planning UI, ensuring all your bookings are easily managed and clearly displayed.

A sidebar at the end of each calendar row summarizes the occupancy of the week. It is added with the renderCalendarSidebarEnd option, while its header cell is customized with the renderCalendarSidebarEndHeader option . The sidebar receives the first and last displayed day of the row together with the events of the row, which are used to calculate the occupancy percentage, the number of booked nights and the number of check-ins for the week. A sidebar can also be added at the start of the rows in the same way.

Get started with this example

Demo

Loading the live demo

Preview in full screen

Show property reservations in a monthly booking calendar — exact check-in/check-out time labels, color-coded by platform.

Code

import { Eventcalendar, setOptions, Toast  } from '@mobiscroll/react';
import { useCallback, useMemo, useState } from 'react';

setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
});

const airBnB = 'https://img.mobiscroll.com/demos/air-bnb-icon.png';
const booking = 'https://img.mobiscroll.com/demos/booking-icon.png';
const makeMyTrip = 'https://img.mobiscroll.com/demos/make-my-trip-icon.png';

// A night is booked when a reservation spans the midnight following the given day
function getWeekSummary(args) {
  const events = args.events || [];
  const day = new Date(args.startDate);
  let nights = 0;
  let bookedNights = 0;
  let checkIns = 0;

  while (day <= args.endDate) {
    const midnight = new Date(day.getFullYear(), day.getMonth(), day.getDate() + 1);
    const isBooked = events.some((ev) => new Date(ev.start) < midnight && new Date(ev.end) > midnight);
    nights++;
    bookedNights += isBooked ? 1 : 0;
    day.setDate(day.getDate() + 1);
  }

  events.forEach((ev) => {
    const start = new Date(ev.start);
    if (start >= args.startDate && start < day) {
      checkIns++;
    }
  });

  const occupancy = nights ? Math.round((bookedNights / nights) * 100) : 0;

  return {
    bookedNights,
    checkIns,
    level: occupancy >= 70 ? 'high' : occupancy >= 40 ? 'medium' : 'low',
    nights,
    occupancy,
  };
}

function App() {
  const [isToastOpen, setToastOpen] = useState(false);

  const myEvents = useMemo(
    () => [
      {
        start: '2026-11-15T12:00',
        end: '2026-11-18T12:00',
        icon: airBnB,
        title: 'Mary Smith',
        color: '#fffa61',
      },
      {
        start: '2026-11-26T12:00',
        end: '2026-12-02T12:00',
        title: 'James Johnson',
        icon: airBnB,
        color: '#fffa61',
      },
      {
        start: '2026-11-21T12:00',
        end: '2026-11-24T12:00',
        title: 'Patricia Williams',
        icon: airBnB,
        color: '#fffa61',
      },
      {
        start: '2026-12-06T12:00',
        end: '2026-12-08T12:00',
        title: 'Michael Brown',
        icon: airBnB,
        color: '#fffa61',
      },
      {
        start: '2026-12-13T12:00',
        end: '2026-12-14T12:00',
        title: 'Jennifer Jones',
        icon: booking,
        color: '#ff9999',
      },
      {
        start: '2026-12-03T12:00',
        end: '2026-12-06T12:00',
        title: 'Robert Garcia',
        icon: booking,
        color: '#ff9999',
      },
      {
        start: '2026-12-22T12:00',
        end: '2026-12-23T12:00',
        title: 'Linda Miller',
        icon: booking,
        color: '#ff9999',
      },
      {
        start: '2026-12-29T12:00',
        end: '2026-12-30T12:00',
        title: 'John Davis',
        icon: booking,
        color: '#ff9999',
      },
      {
        start: '2026-11-18T12:00',
        end: '2026-11-20T12:00',
        title: 'Elizabeth Rodriguez',
        icon: makeMyTrip,
        color: '#a0efaa',
      },
      {
        start: '2026-12-16T12:00',
        end: '2026-12-18T12:00',
        title: 'David Martinez',
        icon: makeMyTrip,
        color: '#a0efaa',
      },
      {
        start: '2026-12-19T12:00',
        end: '2026-12-21T12:00',
        title: 'Barbara Wilson',
        icon: makeMyTrip,
        color: '#a0efaa',
      },
      {
        start: '2026-11-24T12:00',
        end: '2026-11-25T12:00',
        title: 'William Anderson',
        icon: makeMyTrip,
        color: '#a0efaa',
      },
      {
        start: '2026-12-26T12:00',
        end: '2026-12-29T12:00',
        title: 'Susan Taylor',
        icon: makeMyTrip,
        color: '#a0efaa',
      },
      {
        start: '2026-12-09T12:00',
        end: '2026-12-12T12:00',
        title: 'Richard Jackson',
        icon: airBnB,
        color: '#fffa61',
      },
    ],
    [],
  );

  const myView = useMemo(
    () => ({
      calendar: {
        type: 'month',
        eventDisplay: 'exact',
      },
    }),
    [],
  );

  const customDefaultEvent = useCallback((args) => {
    const start = new Date(args.start.setHours(12));
    const end = new Date(args.start.getFullYear(), args.start.getMonth(), args.start.getDate() + 1, 12);
    return {
      title: 'New reservation',
      start,
      end,
    };
  }, []);

  const customLabelContent = useCallback(
    (event) => (
      <div className="mbsc-flex mds-booking-item mbsc-align-items-center">
        {event.original.icon && <img className="mds-booking-icon" draggable="false" src={event.original.icon} />}
        <span>{event.title}</span>
      </div>
    ),
    [],
  );

  const customSidebarHeader = useCallback(() => <div className="mds-booking-summary-header">Occupancy</div>, []);

  const customSidebar = useCallback((args) => {
    const summary = getWeekSummary(args);
    return (
      <div className="mds-booking-summary">
        <div className="mds-booking-summary-value">{summary.occupancy}%</div>
        <div className="mds-booking-summary-bar">
          <div className={'mds-booking-summary-fill mds-booking-summary-' + summary.level} style={{ width: summary.occupancy + '%' }} />
        </div>
        <div className="mds-booking-summary-detail">
          {summary.bookedNights}/{summary.nights} nights
        </div>
        <div className="mds-booking-summary-detail">
          {summary.checkIns} check-in{summary.checkIns === 1 ? '' : 's'}
        </div>
      </div>
    );
  }, []);

  const handleOverlap = useCallback(() => {
    setToastOpen(true);
  }, []);

  const handleCloseToast = useCallback(() => {
    setToastOpen(false);
  }, []);

  return (
    <>
      <Eventcalendar
        cssClass="mds-booking-calendar"
        view={myView}
        data={myEvents}
        clickToCreate={true}
        dragToCreate={true}
        dragToMove={true}
        dragToResize={true}
        eventOverlap={false}
        extendDefaultEvent={customDefaultEvent}
        renderCalendarEventContent={customLabelContent}
        renderCalendarSidebarEnd={customSidebar}
        renderCalendarSidebarEndHeader={customSidebarHeader}
        onEventCreateFailed={handleOverlap}
        onEventUpdateFailed={handleOverlap}
      />
      <Toast message="Reservations cannot overlap" isOpen={isToastOpen} onClose={handleCloseToast} />
    </>
  );
}

export default App;

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.