---
title: "React Timeline Event Buffer Time Example | Mobiscroll"
component: "Timeline"
framework: "React"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/react/timeline/event-buffer"
---

# Event Buffer Time - React Timeline demo

Visualize buffer time on a React Timeline — show travel time, check-in/out, loading/unloading time, or preparation windows around scheduled events. For React and Next.JS.

- [Live demo](https://demo.mobiscroll.com/react/timeline/event-buffer)
- [View React JS code on GitHub](https://github.com/acidb/mobiscroll-demos-react/tree/main/src/demos/eventcalendar/timeline/event-buffer)
- [View React TS code on GitHub](https://github.com/acidb/mobiscroll-demos-react-ts/tree/main/src/demos/eventcalendar/timeline/event-buffer)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/javascript/timeline/event-buffer.md), [jQuery](https://demo.mobiscroll.com/jquery/timeline/event-buffer.md), [Angular](https://demo.mobiscroll.com/angular/timeline/event-buffer.md), [Vue](https://demo.mobiscroll.com/vue/timeline/event-buffer.md)

## Description

Use the `bufferBefore` and `bufferAfter` to add buffer times that will be rendered before and after the event.

These areas can help you visualize delays or added minutes for tasks. Here are some examples:

- Travel time for meetings, appointments, work orders
- Check in and check out times around flights
- Loading/unloading for bus/truck
- Cleaning, inspection, maintenance work that happen on a recurring basis

**Looking to customize event buffers?** [Check out the templating capabilities →](https://demo.mobiscroll.com/react/timeline/timeline-custom-event-rendering)

## What this demo shows

- A desktop timeline showing a single day with hours arranged horizontally and resources arranged vertically.
- **Header navigation** The month and year label opens date navigation, while the previous and next arrows and the Today button move between dates and return to the current day.
- **Day view** A fixed date strip below the header shows the selected date in `DD DDD MMM YYYY` format, with the current date highlighted.
- **Time grid** The timeline displays hourly columns from 12 AM to 12 PM.
- **Resources** Multiple resources appear as separate rows on the left side of the timeline.
- **Current time** A vertical blue line with a time label marks the current time.
- **Hover behavior** Hovering over the time grid shows a time indicator that follows the cursor in 15-minute increments.
- **Event cards** Events appear as colored cards with a left color stripe, the time range below the title, and the title shown in bold.
- **Event buffers** When event buffer display is enabled, buffer time renders before and/or after the event block to show added time around the scheduled event.
- **Buffer control** A control above the timeline lets users turn event buffer display on or off. Buffer display is enabled by default.
- **Event overlapping** Overlapping events are placed side by side so each event remains visible.
- **Event positioning** Events are positioned by assigned resource, date, start time, and end time.
- **Event interaction** Events highlight on hover and expose drag and resize handles for moving events or changing their duration.
- **Event selection** Clicking an event selects and highlights it.
- **Event creation** Users can create events by double-clicking the timeline or by clicking and dragging across a time range.
- **Scrolling** The timeline supports horizontal and vertical scrolling for navigating through time and resources.

## Best for

- **Travel time** Showing travel time before or after meetings, appointments, and work orders.
- **Check-in and check-out windows** Visualizing time around flights, bookings, or scheduled appointments.
- **Loading and unloading time** Planning additional time around bus, truck, delivery, or transport work.
- **Preparation and cleanup work** Displaying cleaning, inspection, maintenance, or other recurring work that happens before or after the main scheduled event.
- **Delay visibility** Making added minutes or expected delays visible directly in the timeline.

## Tutorial

### Control the event buffer display globally

- [x] Turn event buffer display ON/OFF

```jsx
// event example
const myData = [{
    bufferBefore: 30,
    bufferAfter: 120,
    start: '2026-10-26T16:00',
    end: '2026-10-26T20:00',
    title: 'Friends binge marathon',
    resource: 4,
},{
    bufferAfter: 30,
    start: '2026-10-26T06:00',
    end: '2026-10-26T08:00',
    title: 'Morning routine',
    resource: 1,
}, {
    bufferBefore: 45,
    start: '2026-10-26T09:30',
    end: '2026-10-26T12:00',
    title: 'Product team mtg.',
    resource: 4,
}];

<Eventcalendar
    view={{
        timeline: { type: 'day' }
    }}
    showEventBuffer={true}
    data={myData}
/>
```

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-themeVariant) - option
- [`clickToCreate`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-clickToCreate) - option
- [`dragToCreate`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-dragToCreate) - option
- [`dragToMove`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-dragToMove) - option
- [`dragToResize`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-dragToResize) - option
- [`eventDelete`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-eventDelete) - option
- [`showEventBuffer`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-showEventBuffer) - option
- [`data`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-data) - option
- [`view`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-view) - option
- [`resources`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-resources) - option

## Code

### JSX

```jsx
import { Eventcalendar, setOptions } from '@mobiscroll/react';
import { useMemo } from 'react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

function App() {
  const myEvents = useMemo(
    () => [
      {
        bufferAfter: 30,
        start: '2026-10-26T06:00',
        end: '2026-10-26T08:00',
        title: 'Morning routine',
        resource: 1,
      },
      {
        bufferAfter: 120,
        bufferBefore: 30,
        start: '2026-10-26T16:00',
        end: '2026-10-26T20:00',
        title: 'Friends binge marathon',
        resource: 4,
      },
      {
        bufferAfter: 120,
        bufferBefore: 30,
        start: '2026-10-26T13:00',
        end: '2026-10-26T21:00',
        title: 'Mastering CSS class',
        resource: 2,
      },
      {
        bufferAfter: 10,
        bufferBefore: 15,
        start: '2026-10-26T08:00',
        end: '2026-10-26T10:00',
        title: 'Product team mtg.',
        resource: 2,
      },
      {
        bufferAfter: 20,
        bufferBefore: 30,
        start: '2026-10-26T16:30',
        end: '2026-10-26T19:30',
        title: 'Cinema afternoon',
        resource: 3,
      },
      {
        bufferAfter: 10,
        bufferBefore: 10,
        start: '2026-10-26T08:30',
        end: '2026-10-26T10:00',
        title: 'Quick mtg. with Martin',
        resource: 3,
      },
      {
        bufferBefore: 45,
        start: '2026-10-26T09:30',
        end: '2026-10-26T12:00',
        title: 'Product team mtg.',
        resource: 4,
      },
    ],
    [],
  );

  const myResources = [
    {
      id: 1,
      name: 'Resource 1',
      color: '#e20000',
    },
    {
      id: 2,
      name: 'Resource 2',
      color: '#76e083',
    },
    {
      id: 3,
      name: 'Resource 3',
      color: '#4981d6',
    },
    {
      id: 4,
      name: 'Resource 4',
      color: '#f7961e',
    },
  ];

  const view = useMemo(() => ({ timeline: { type: 'day' } }), []);

  return (
    <Eventcalendar
      clickToCreate={true}
      dragToCreate={true}
      dragToMove={true}
      dragToResize={true}
      eventDelete={true}
      showEventBuffer={true}
      data={myEvents}
      view={view}
      resources={myResources}
    />
  );
}

export default App;
```

### TSX

```tsx
import { Eventcalendar, MbscCalendarEvent, MbscEventcalendarView, MbscResource, setOptions } from '@mobiscroll/react';
import { FC, useMemo } from 'react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

const App: FC = () => {
  const myEvents = useMemo<MbscCalendarEvent[]>(
    () => [
      {
        bufferAfter: 30,
        start: '2026-10-26T06:00',
        end: '2026-10-26T08:00',
        title: 'Morning routine',
        resource: 1,
      },
      {
        bufferAfter: 120,
        bufferBefore: 30,
        start: '2026-10-26T16:00',
        end: '2026-10-26T20:00',
        title: 'Friends binge marathon',
        resource: 4,
      },
      {
        bufferAfter: 120,
        bufferBefore: 30,
        start: '2026-10-26T13:00',
        end: '2026-10-26T21:00',
        title: 'Mastering CSS class',
        resource: 2,
      },
      {
        bufferAfter: 10,
        bufferBefore: 15,
        start: '2026-10-26T08:00',
        end: '2026-10-26T10:00',
        title: 'Product team mtg.',
        resource: 2,
      },
      {
        bufferAfter: 20,
        bufferBefore: 30,
        start: '2026-10-26T16:30',
        end: '2026-10-26T19:30',
        title: 'Cinema afternoon',
        resource: 3,
      },
      {
        bufferAfter: 10,
        bufferBefore: 10,
        start: '2026-10-26T08:30',
        end: '2026-10-26T10:00',
        title: 'Quick mtg. with Martin',
        resource: 3,
      },
      {
        bufferBefore: 45,
        start: '2026-10-26T09:30',
        end: '2026-10-26T12:00',
        title: 'Product team mtg.',
        resource: 4,
      },
    ],
    [],
  );

  const myResources = useMemo<MbscResource[]>(
    () => [
      {
        id: 1,
        name: 'Resource 1',
        color: '#e20000',
      },
      {
        id: 2,
        name: 'Resource 2',
        color: '#76e083',
      },
      {
        id: 3,
        name: 'Resource 3',
        color: '#4981d6',
      },
      {
        id: 4,
        name: 'Resource 4',
        color: '#f7961e',
      },
    ],
    [],
  );

  const view = useMemo<MbscEventcalendarView>(() => ({ timeline: { type: 'day' } }), []);

  return (
    <Eventcalendar
      clickToCreate={true}
      dragToCreate={true}
      dragToMove={true}
      dragToResize={true}
      eventDelete={true}
      showEventBuffer={true}
      data={myEvents}
      view={view}
      resources={myResources}
    />
  );
};
export default App;
```

## Implementation notes

- Set `timeline: { type: 'day' }` for a single-day timeline view showing all resources as rows.
- Enable buffer rendering by setting `showEventBuffer: true` on the `Eventcalendar` component. Without this prop the buffer zones are not displayed even if events carry buffer data.
- Add `bufferBefore` and/or `bufferAfter` to individual event objects. Both values are in minutes and are independent - an event can have only before, only after, or both. The buffer zone is rendered as a distinct shaded area adjacent to the event block.
- Define 4 resources with `id`, `name`, and `color`. Use today's date with time offsets (via a relative date helper) for event `start` and `end` so events always appear on the current day.
- Include a variety of buffer combinations to illustrate all cases: `bufferAfter` only (e.g. 30 min after morning routine), `bufferBefore` + `bufferAfter` (e.g. 30 min before and 120 min after a long session), and small symmetric buffers (e.g. 10 min on both sides of a short meeting).

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-react.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config react
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config react --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/react/getting-started/installation

## Related demos

- Previous: [Limit Concurrent Events](https://demo.mobiscroll.com/react/timeline/control-number-of-concurrently-shown-events.md) - Set a maximum number of concurrent events on a React Timeline — cap overlapping events per row and show an overflow indicator for hidden events.
- Next: [Custom Range Picker View](https://demo.mobiscroll.com/react/timeline/custom-range-view.md) - Replace the React Timeline's default header navigation with a range picker — let users set any custom date range, synced two-way with the timeline.
