> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/sdk-core-ui/components/calendar.md). Agents can also search and read this documentation through its [MCP server](https://docs.rierino.com/~gitbook/mcp).

# Calendar

Shows events on a month, week, day or agenda calendar, and lets people move them.

{% code title="calendar/demo.tsx" %}

```tsx
import { useState } from "react";
import { Calendar, type CalendarEvent } from "@rierino-open/core-ui";

const day = (offset: number, hour: number) => {
  const d = new Date(2026, 5, 15 + offset);
  d.setHours(hour, 0, 0, 0);
  return d;
};

export default function CalendarDemo() {
  const [events, setEvents] = useState<CalendarEvent[]>([
    { id: 1, title: "Summer sale starts", start: day(0, 9), end: day(0, 10) },
    { id: 2, title: "Photo shoot", start: day(2, 13), end: day(2, 16), background: "#33cca1" },
    { id: 3, title: "Stock count", start: day(4, 0), end: day(5, 0), allDay: true, background: "#ff7e47" },
  ]);

  return (
    <div style={{ width: "100%" }}>
      <Calendar
        events={events}
        defaultDate={new Date(2026, 5, 15)}
        style={{ height: 520 }}
        onEventDrop={({ event, start, end }) =>
          setEvents((current) =>
            current.map((e) => (e.id === event.id ? { ...e, start: new Date(start), end: new Date(end) } : e))
          )
        }
      />
    </div>
  );
}
```

{% endcode %}

## Usage

{% tabs %}
{% tab title="React app" %}

```tsx
import { Calendar } from '@rierino-open/core-ui';

<Calendar
  events={[
    { id: 1, title: 'Summer sale starts', start: new Date(2026, 5, 15, 9), end: new Date(2026, 5, 15, 10) },
  ]}
  style={{ height: 520 }}
/>
```

{% endtab %}

{% tab title="Hosted editor" %}

```jsx
import CoreUI from '@rierino-open/core-ui';
const { Calendar } = CoreUI;

<Calendar
  events={[
    { id: 1, title: 'Summer sale starts', start: new Date(2026, 5, 15, 9), end: new Date(2026, 5, 15, 10) },
  ]}
  style={{ height: 520 }}
/>
```

{% endtab %}
{% endtabs %}

Calendar is built on [react-big-calendar](https://jquense.github.io/react-big-calendar/), with Rierino's defaults: weeks start on Monday, the month view is shown first, and it opens on today. Its styles are included in Core UI's stylesheet.

Each event needs an `id`, a `title`, and `start` and `end` dates. Set `allDay` for events without a time. The `CalendarEvent` type, exported from the package, describes them.

{% hint style="info" %}
**Give the calendar a height**

The calendar fills the height you give it in `style`, and is 600px tall by default.
{% endhint %}

## Examples

### Moving events

Drag and drop is on by default: events can be dragged to other days or times. Calendar doesn't change your data itself. Handle `onEventDrop`, which receives the event and its new `start` and `end`, and update `events`, as in the example at the top. Add `resizable` and handle `onEventResize` to let people change an event's length by dragging its edge.

### Colours and tooltips

`background` on an event sets its colour, as a hex code such as `#33cca1`. The text turns black or white, whichever contrasts better. Hovering an event shows a tooltip with its title, start and end, and its `description` if it has one.

### Week view

`defaultView` sets the first view: `month`, `week`, `work_week`, `day` or `agenda`. People can switch views from the toolbar. In the week and day views, `step` sets the slot length in minutes and `timeslots` the slots per hour row.

{% code title="calendar/week.tsx" %}

```tsx
import { Calendar, type CalendarEvent } from "@rierino-open/core-ui";

const at = (offset: number, hour: number) => new Date(2026, 5, 15 + offset, hour);

const events: CalendarEvent[] = [
  { id: 1, title: "Supplier call", start: at(0, 10), end: at(0, 11) },
  { id: 2, title: "Catalogue review", start: at(1, 14), end: at(1, 16), background: "#847ef6" },
  { id: 3, title: "Launch", start: at(3, 9), end: at(3, 12), background: "#eb475a" },
];

export default function CalendarWeek() {
  return (
    <div style={{ width: "100%" }}>
      <Calendar
        events={events}
        defaultView="week"
        defaultDate={new Date(2026, 5, 15)}
        dragAndDrop={false}
        style={{ height: 520 }}
      />
    </div>
  );
}
```

{% endcode %}

For a controlled view, pass `view` and update it from `onView`.

### Selecting dates

`selectable` lets people click or drag across empty days or times, which calls `onSelectSlot` with the selection's `start` and `end`. Use it to create events. `onSelectEvent` is called when an event is clicked.

{% code title="calendar/selectable.tsx" %}

```tsx
import { useState } from "react";
import { Calendar, type CalendarEvent } from "@rierino-open/core-ui";

export default function CalendarSelectable() {
  const [events, setEvents] = useState<CalendarEvent[]>([]);
  const [picked, setPicked] = useState("nothing yet");

  return (
    <div style={{ width: "100%", display: "grid", gap: 8, fontSize: 12 }}>
      <Calendar
        events={events}
        defaultDate={new Date(2026, 5, 15)}
        dragAndDrop={false}
        selectable
        style={{ height: 480 }}
        onSelectSlot={(slot) =>
          setEvents((current) => [
            ...current,
            { id: current.length + 1, title: "New promotion", start: slot.start, end: slot.end, allDay: true },
          ])
        }
        onSelectEvent={(event) => setPicked(String(event.title))}
      />
      <span>Clicked event: {picked}</span>
    </div>
  );
}
```

{% endcode %}

## Other react-big-calendar props

Calendar passes every other prop to react-big-calendar, so its full [API](https://jquense.github.io/react-big-calendar/examples/?path=/docs/props--page) works, for example `date` and `onNavigate` for a controlled date, `views` to limit the views, `min` and `max` for the day's hours, `toolbar`, `formats` and `messages` to translate the toolbar.

Dates are formatted in English. `culture="tr"` switches them to Turkish, the only other locale included.

## Accessibility

react-big-calendar is a pointer-driven interface. Its toolbar buttons can be reached with `Tab`, but events can't be focused, and dragging, resizing and selecting dates need a mouse or touch. When people must be able to open or change events with the keyboard, offer another way to do it, such as a list or a form.

## Styling

Calendar uses react-big-calendar's own classes, such as `.rbc-toolbar`, `.rbc-event`, `.rbc-today` and `.rbc-off-range-bg`, so style it by targeting those from your own CSS. `className` and `style` apply to the calendar's container.

## API reference

### Calendar

| Prop            | Type                                            | Default           | Description                                                                               |
| --------------- | ----------------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------- |
| `onEventDrop`   | `((args: EventInteractionArgs<Event>) => void)` |                   |                                                                                           |
| `onEventResize` | `((args: EventInteractionArgs<Event>) => void)` |                   |                                                                                           |
| `events`        | `Event[]`                                       |                   | **Required.** The events to show.                                                         |
| `defaultView`   | `View`                                          | `"month"`         | The view shown first: `month`, `week`, `work_week`, `day` or `agenda`.                    |
| `defaultDate`   | `Date`                                          | `today`           | The date shown first.                                                                     |
| `view`          | `View`                                          |                   | The current view, for a controlled calendar. Update it from `onView`.                     |
| `onView`        | `((v: View) => void)`                           |                   | Called with the new view when the user switches views.                                    |
| `step`          | `number`                                        | `30`              | The length of a time slot in minutes, in the week and day views.                          |
| `timeslots`     | `number`                                        | `2`               | The number of slots per labelled hour row, in the week and day views.                     |
| `selectable`    | `boolean`                                       |                   | Lets people select empty dates or times, which calls `onSelectSlot`.                      |
| `popup`         | `boolean`                                       |                   | Shows "+n more" in a month cell that has more events than fit, and opens them in a popup. |
| `resizable`     | `boolean`                                       |                   | Lets people resize events by dragging their edges. Needs `dragAndDrop`.                   |
| `dragAndDrop`   | `boolean`                                       | `true`            | Lets people move events by dragging them. Handle `onEventDrop` to save the new dates.     |
| `onSelectSlot`  | `((slot: SlotInfo) => void)`                    |                   | Called with the selected dates or times, when `selectable` is set.                        |
| `onSelectEvent` | `((slot: Event) => void)`                       |                   | Called with the event when it is clicked.                                                 |
| `style`         | `React.CSSProperties`                           | `{ height: 600 }` | Styles for the calendar. Set a `height`: the calendar fills it.                           |

### Event

| Prop          | Type               | Default | Description                                                                                         |
| ------------- | ------------------ | ------- | --------------------------------------------------------------------------------------------------- |
| `allDay`      | `boolean`          |         |                                                                                                     |
| `title`       | `React.ReactNode`  |         |                                                                                                     |
| `start`       | `Date`             |         |                                                                                                     |
| `end`         | `Date`             |         |                                                                                                     |
| `id`          | `string \| number` |         | **Required.** A unique id for the event.                                                            |
| `background`  | `string`           |         | The event's colour, as a hex code such as `#33cca1`. The text colour is chosen to contrast with it. |
| `description` | `string`           |         | Shown in the tooltip when the event is hovered.                                                     |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/sdk-core-ui/components/calendar.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
