Build a React Calendar Component with Events (react-big-calendar)

My marketing team wanted one page with every meeting, call and launch for the month. The fastest way to build a React calendar component with events is react-big-calendar: give it a localizer and an array of objects with a title, start and end.

<Calendar
  localizer={localizer}
  events={events}          // { title, start: Date, end: Date }[]
  startAccessor="start"
  endAccessor="end"
  style={{ height: 560 }}
/>

In this tutorial, I’ll build a React calendar component with events one step at a time: a month view, a week view, color-coded categories, a details panel on click and new events added by clicking a day.

Everything ran on React 19.3, react-big-calendar 1.20.0, date-fns 4.4.0, TypeScript 7.0.2 and Vite 8.3, and each screenshot is what Microsoft Edge rendered.

Here’s what we’re building:

React calendar component with events showing November 2026 with color-coded team events and a details panel for Thanksgiving
The finished calendar: events colored by category, and the details panel after clicking Thanksgiving.

Before You Start: What Do You Need for This React Calendar?

You need Node.js and a React + TypeScript project. A Vite project takes a minute to create. If typing props and state is new to you, skim these React component types in TypeScript first.

npm create vite@latest team-calendar -- --template react-ts
cd team-calendar
npm install react-big-calendar date-fns
npm install -D @types/react-big-calendar

react-big-calendar 1.20.0 lists React 16.14 through 19 as peers, so the install went through cleanly on React 19.

Every step reuses the same sample: six events for a US marketing team in November 2026. Each event needs these fields:

FieldTypeNotes
titlestringText shown on the event
startDateA real Date, not a string
endDateExclusive for all-day events: Nov 13 ends the Nov 12 launch
allDaybooleanPuts the event in the all-day row of the week view
categorystringOur own field; we’ll use it for colors

Save the data as src/events.ts:

export type Category = "meeting" | "client" | "launch" | "holiday";

export interface TeamEvent {
  id: number;
  title: string;
  start: Date;
  end: Date;
  allDay?: boolean;
  category: Category;
}

// months are 0-based in JavaScript: 10 = November
export const events: TeamEvent[] = [
  { id: 1, title: "Q4 budget review", category: "meeting",
    start: new Date(2026, 10, 4, 10, 0), end: new Date(2026, 10, 4, 11, 30) },
  { id: 2, title: "Client call: Harper & Lane", category: "client",
    start: new Date(2026, 10, 10, 14, 0), end: new Date(2026, 10, 10, 15, 0) },
  { id: 3, title: "Atlas app launch", category: "launch", allDay: true,
    start: new Date(2026, 10, 12), end: new Date(2026, 10, 13) },
  { id: 4, title: "Design sprint", category: "meeting", allDay: true,
    start: new Date(2026, 10, 16), end: new Date(2026, 10, 19) },
  { id: 5, title: "Client call: Ortega Dental", category: "client",
    start: new Date(2026, 10, 24, 11, 0), end: new Date(2026, 10, 24, 11, 45) },
  { id: 6, title: "Thanksgiving (office closed)", category: "holiday",
    allDay: true, start: new Date(2026, 10, 26), end: new Date(2026, 10, 28) },
];

Step 1: Set Up the react-big-calendar Localizer with date-fns

react-big-calendar doesn’t format dates itself. It asks a localizer, a small adapter around a date library, for things like the first day of the week.

We’ll use date-fns. Put this at the top of src/App.tsx:

import { Calendar, dateFnsLocalizer } from "react-big-calendar";
import { format, parse, startOfWeek, getDay } from "date-fns";
import { enUS } from "date-fns/locale";
import "react-big-calendar/lib/css/react-big-calendar.css";
import { events } from "./events";

const localizer = dateFnsLocalizer({
  format,
  parse,
  startOfWeek,
  getDay,
  locales: { "en-US": enUS },
});

Important: don’t skip the CSS import. Without react-big-calendar.css the calendar renders as unstyled text with no grid lines.

Step 2: Render the Month View with Your Events

Now add the component below the localizer. The parent div gets a fixed height, and the calendar fills it:

// below the localizer from Step 1
export default function App() {
  return (
    <div style={{ height: 560, padding: 12 }}>
      <Calendar
        localizer={localizer}
        events={events}
        defaultDate={new Date(2026, 10, 1)}
        startAccessor="start"
        endAccessor="end"
        style={{ height: "100%" }}
      />
    </div>
  );
}
react-big-calendar month view for November 2026 showing six team events in the default blue
The month view with all six events in the default blue.

defaultDate opens November 2026. startAccessor and endAccessor name the date fields; change them only if your data uses other names.

VS Code with the react-big-calendar App.tsx open and the terminal running tsc and the Vite dev server on port 5173
The same App.tsx in VS Code: tsc passes in strict mode and Vite serves it on port 5173.

Checkpoint: you should see November 2026 with six events. Thanksgiving spans Thursday and Friday, and the design sprint covers Monday through Wednesday of the third week.

Step 3: Switch Between Month and Week View in react-big-calendar

With defaultDate the calendar keeps its own state. To read or change the date and view from your code, hold both in useState and pass date, view, onNavigate and onView. It’s the same controlled vs uncontrolled choice you make with form inputs.

// imports + localizer: same as Step 1 (add useState, Views and View)

export default function App() {
  const [date, setDate] = useState(new Date(2026, 10, 10));
  const [view, setView] = useState<View>(Views.MONTH);

  return (
    <div style={{ height: 600, padding: 12 }}>
      <Calendar
        localizer={localizer}
        events={events}
        date={date}
        view={view}
        views={[Views.MONTH, Views.WEEK, Views.DAY, Views.AGENDA]}
        onNavigate={(next) => setDate(next)}
        onView={(next) => {
          console.log("view:", next);
          setView(next);
        }}
        scrollToTime={new Date(2026, 10, 10, 9, 0)}
        style={{ height: "100%" }}
      />
    </div>
  );
}

Console output after clicking Week in the toolbar:

view: week
react-big-calendar week view for November 8-14, 2026 with the Atlas app launch in the all-day row and a client call at 2 PM
After a real click on Week: the all-day launch sits in the top row and the client call fills 2:00 to 3:00 PM.

scrollToTime opens the week view at 9 AM instead of midnight, and views picks the toolbar buttons.

Step 4: Color Events by Category with eventPropGetter

eventPropGetter runs once per event and returns props for its wrapper, usually a className or style. We look up the color from the event’s category (the legend in the shot is just a map over colors):

const colors: Record<Category, string> = {
  meeting: "#1c7ed6",
  client: "#2f9e44",
  launch: "#e8590c",
  holiday: "#868e96",
};

// add to <Calendar>:
eventPropGetter={(event) => ({
  style: { backgroundColor: colors[event.category], border: "none" },
})}
React calendar events colored by category: blue meetings, green client calls, orange launch and gray holiday, with a legend
Blue meetings, green client calls, an orange launch and a gray holiday.

TypeScript infers the event type from events, so a typo in the color map fails the build.

Step 5: Show Event Details When Someone Clicks an Event

onSelectEvent fires with the clicked event object. Store it in state, and render a side panel only when something is selected. That’s plain React event handling plus a conditional render:

function when(e: TeamEvent): string {
  if (e.allDay) return format(e.start, "EEEE, MMM d") + " (all day)";
  return `${format(e.start, "EEE, MMM d, h:mm a")} - ${format(e.end, "h:mm a")}`;
}

// inside App:
const [selected, setSelected] = useState<TeamEvent | null>(null);

// add to <Calendar>:
onSelectEvent={(event) => {
  console.log("selected:", event.title, "|", when(event));
  setSelected(event);
}}

// next to <Calendar>, inside a flex row:
{selected && (
  <aside id="details">
    <h3>{selected.title}</h3>
    <p>{when(selected)}</p>
    <p>Category: {selected.category}</p>
    <button onClick={() => setSelected(null)}>Close</button>
  </aside>
)}

Console output after clicking the Harper & Lane call:

selected: Client call: Harper & Lane | Tue, Nov 10, 2:00 PM - 3:00 PM
React calendar with a details panel on the right showing the Harper and Lane client call on Tuesday, Nov 10 from 2:00 PM to 3:00 PM
Clicking the Harper & Lane event opens the panel with its day, time and category.

Checkpoint: the panel reads Tue, Nov 10, 2:00 PM – 3:00 PM. Close clears the state, and the calendar takes the full width again.

Step 6: Add New Events by Clicking an Empty Day

Set selectable and the calendar calls onSelectSlot when someone clicks or drags across empty days. We keep the slot in state, show a title