---
title: "Angular Timeline Event Appearance & Time Buffers Example | Mobiscroll"
component: "Timeline"
framework: "Angular"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/angular/timeline/timeline-custom-event-rendering"
---

# Event Appearance & Time Buffers - Angular Timeline demo

Customize event layouts on a Angular Timeline with icons, labels, and colors — visualize before/after buffers for travel, prep, or inspection workflows. For Angular 22 and Ionic 8.

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

## Description

Events can be customized through the [`timelineEventTemplate`](https://mobiscroll.com/docs/angular/eventcalendar/api#template-timelineEventTemplate). How the events look are fully up to you. Base event fields along with custom fields can be accessed when writing the event template.

The before/after buffers can help you visualise delays or added minutes for tasks. For example travel time for meetings/appointments, check in/check out for flights.

Templating the buffers are handled through the [`bufferBeforeTemplate`](https://mobiscroll.com/docs/angular/eventcalendar/api#template-bufferBeforeTemplate) and [`bufferAfterTemplate`](https://mobiscroll.com/docs/angular/eventcalendar/api#template-bufferAfterTemplate) options.

**Want to see how custom event rendering looks on the time grid?** [Check out this example →](https://demo.mobiscroll.com/angular/scheduler/customizing-events)

## What this demo shows

- A desktop timeline day view where hours are arranged horizontally and resources are listed as rows on the left.
- **Header navigation** The month and year label opens date navigation, the previous and next arrows move between days, and the Today button returns to the current date.
- **Day view** The strip below the header shows the selected day, with the current date highlighted.
- **Timeline grid** The timeline displays hourly columns for the selected day.
- **Resources** Resources are shown as separate timeline rows.
- **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 labels** Events use custom timeline rendering with a colored icon, a colored start time, and the event title inside the event body.
- **Buffers** Events include before and after buffer areas labeled Prep and Inspection, with the required time shown for each buffer.
- **Date positioning** Events are positioned by assigned resource and exact date and time range.
- **Event interaction** Hovering over events reveals drag and resize handles for repositioning events or changing their duration.
- **Event creation** New events can be created 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

- **Custom timeline event rendering** Timeline views that need event labels to match product-specific visual requirements instead of using the default event layout.
- **Resource-based scheduling** Timelines where events are assigned to people, teams, equipment, rooms, or other resources.
- **Project or category-based scheduling** Timelines where color, icons, labels, or visual accents help users distinguish projects, categories, teams, or statuses.
- **Detailed event summaries** Scheduling interfaces that need to show additional event context, such as start time, custom fields, task type, or status.
- **Preparation and follow-up buffers** Workflows where time before or after an event needs to be shown separately from the main scheduled task.
- **Field service workflows** Maintenance, inspection, repair, and asset management applications where each appointment may include preparation, the main task, and post-task inspection.

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-themeVariant) - option
- [`view`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-view) - option
- [`data`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-data) - option
- [`resources`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-resources) - option
- [`timelineEventTemplate`](https://mobiscroll.com/docs/angular/eventcalendar/api#template-timelineEventTemplate) - template
- [`bufferBeforeTemplate`](https://mobiscroll.com/docs/angular/eventcalendar/api#template-bufferBeforeTemplate) - template
- [`bufferAfterTemplate`](https://mobiscroll.com/docs/angular/eventcalendar/api#template-bufferAfterTemplate) - template
- [`extendDefaultEvent`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-extendDefaultEvent) - option

## Code

### Component

```ts
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { MbscCalendarEvent, MbscEventcalendarView, MbscModule, setOptions } from '@mobiscroll/angular';

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

@Component({
  selector: 'app-root', 
  templateUrl: './app.component.html',
  standalone: true,
  imports: [CommonModule, MbscModule],
})
export class AppComponent {
  view: MbscEventcalendarView = {
    timeline: {
      type: 'day',
    },
  };

  myEvents: MbscCalendarEvent[] = [
    {
      bufferBefore: 30,
      bufferAfter: 35,
      start: '2026-10-22T10:30',
      end: '2026-10-22T13:00',
      title: 'Tire change',
      color: '#7a5886',
      taskType: 'material-repeat',
      resource: 1,
    },
    {
      bufferAfter: 40,
      bufferBefore: 30,
      start: '2026-10-22T07:00',
      end: '2026-10-22T10:00',
      title: 'Brake maintenance',
      color: '#9da721',
      taskType: 'cogs',
      resource: 2,
    },
    {
      bufferAfter: 45,
      bufferBefore: 30,
      start: '2026-10-22T13:30',
      end: '2026-10-22T16:30',
      title: 'Fluid maintenance',
      color: '#cd6957',
      taskType: 'cogs',
      resource: 1,
    },
    {
      bufferAfter: 35,
      bufferBefore: 30,
      start: '2026-10-22T11:00',
      end: '2026-10-22T14:00',
      title: 'Oil change',
      color: '#637e57',
      taskType: 'material-repeat',
      resource: 3,
    },
    {
      bufferAfter: 60,
      bufferBefore: 30,
      start: '2026-10-22T08:00',
      end: '2026-10-22T12:00',
      title: 'Engine repair',
      color: '#6c5d45',
      taskType: 'material-search',
      resource: 3,
    },
    {
      bufferAfter: 45,
      bufferBefore: 30,
      start: '2026-10-22T14:00',
      end: '2026-10-22T19:00',
      title: 'Car painting',
      color: '#50789d',
      taskType: 'material-format-paint',
      resource: 2,
    },
  ];

  myResources = [
    {
      id: 1,
      name: 'Ryan',
      color: '#239a21',
    },
    {
      id: 2,
      name: 'Kate',
      color: '#01adff',
    },
    {
      id: 3,
      name: 'John',
      color: '#ff0101',
    },
  ];

  myDefaultEvent() {
    return {
      taskType: 'cogs',
      bufferAfter: 60,
      bufferBefore: 30,
    };
  }
}
```

### Template

```html
<mbsc-eventcalendar
  [view]="view"
  [data]="myEvents"
  [resources]="myResources"
  [timelineEventTemplate]="eventTemplate"
  [bufferBeforeTemplate]="bufferBefore"
  [bufferAfterTemplate]="bufferAfter"
  [extendDefaultEvent]="myDefaultEvent"
  class="md-timeline-template"
></mbsc-eventcalendar>

<ng-template #eventTemplate let-data>
  <div class="md-timeline-template-event" [ngStyle]="{borderColor: data.color, background: data.color}">
    <div class="md-timeline-template-event-cont">
      <span class="mbsc-icon mbsc-font-icon mbsc-icon-{{data.original.taskType}}" [ngStyle]="{background: data.color}"></span>
      <span class="md-timeline-template-time" [ngStyle]="{color: data.color}">{{data.start}}</span>
      <span class="md-timeline-template-title">{{data.original.title}}</span>
    </div>
  </div>
</ng-template>

<ng-template #bufferBefore let-data>
  <div class="md-buffer md-after-buffer" [ngStyle]="{background: data.original.color}">
    Inspection
    <span class="md-buffer-time">{{ data.original.bufferAfter}}min</span>
    <div class="md-buffer-tail" [ngStyle]="{background: data.original.color}"></div>
  </div>
</ng-template>

<ng-template #bufferAfter let-data>
  <div class="md-buffer md-after-buffer" [ngStyle]="{background: data.original.color}">
    Prep
    <span class="md-buffer-time">{{ data.original.bufferBefore}}min</span>
    <div class="md-buffer-tail" [ngStyle]="{background: data.original.color}"></div>
  </div>
</ng-template>
```

### CSS

```css
.md-timeline-template .mbsc-schedule-event.mbsc-ltr {
  height: auto !important;
}

.md-timeline-template-event {
  border: 1px solid transparent;
  margin: 2px 0;
}

.md-timeline-template-event-cont {
  background: rgba(255, 255, 255, 0.8);
  font-size: 15px;
  height: 32px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.md-timeline-template-event-cont .mbsc-icon {
  padding: 5px;
  box-sizing: content-box;
}

.md-after-buffer,
.mbsc-timeline-event-start .md-timeline-template-event,
.mbsc-timeline-event-start .md-timeline-template-event-cont,
.mbsc-timeline-event-start .md-timeline-template-event-cont .mbsc-icon {
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
}

.md-after-buffer,
.mbsc-timeline-event-end .md-timeline-template-event,
.mbsc-timeline-event-end .md-timeline-template-event-cont,
.mbsc-timeline-event-end .md-timeline-template-event-cont .mbsc-icon {
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
}

.md-buffer {
  position: absolute;
  display: flex;
  width: 100%;
  font-size: 10px;
  top: 2px;
  bottom: 2px;
  left: 0;
  color: #fff;
  padding: 0 6px;
  line-height: 12px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0.5;
  box-sizing: border-box;
  z-index: -1;
}

.md-buffer-tail {
  position: absolute;
  width: 14px;
  height: 100%;
  top: 0;
}

.md-before-buffer .md-buffer-tail {
  left: 100%;
}

.md-after-buffer .md-buffer-tail {
  right: 100%;
}

.md-buffer-time {
  font-weight: 600;
}

.md-timeline-template-event-cont .mbsc-icon:before {
  color: #fff;
  font-size: 18px;
}

.md-timeline-template-time {
  margin: 0 10px;
}

.md-timeline-template-title {
  color: #666;
}

.md-timeline-template .mbsc-timeline-column,
.md-timeline-template .mbsc-timeline-header-column {
  min-width: 100px;
}

.md-timeline-template .mbsc-timeline-resource,
.md-timeline-template .mbsc-timeline-row {
  min-height: 100px;
}
```

## Implementation notes

- Use `timeline: { type: 'day' }` for a single-day view with all resources as rows.
- Define 3 person resources (Ryan, Kate, John), each with `id`, `name`, and `color`. Event colors are set per-event independently of resource colors.
- Add a custom `taskType` property to each event containing a Mobiscroll icon name string (e.g. `'cogs'`, `'material-repeat'`, `'material-search'`, `'material-format-paint'`). Each event also carries `bufferBefore` and `bufferAfter` values in minutes. Use `dyndatetime` offsets so events always fall on today.
- Use `renderTimelineEvent` (Angular: `timelineEventTemplate`, Vue: `#timelineEvent`) to fully replace the default event rendering. The render function receives `data` with `data.original` (the raw event object), `data.color` (the resolved event color), and `data.start` (a pre-formatted start time string). Render a Mobiscroll icon via the class `mbsc-icon mbsc-font-icon mbsc-icon-{taskType}`, the formatted start time, and the event title.
- Use `renderBufferBefore` (Angular: `bufferBeforeTemplate`, Vue: `#bufferBefore`) and `renderBufferAfter` (Angular: `bufferAfterTemplate`, Vue: `#bufferAfter`) to render custom buffer zones. Both receive `args.original` (the event). Render "Prep" with `event.bufferBefore` minutes in the before-buffer, and "Inspection" with `event.bufferAfter` minutes in the after-buffer.
- Use `extendDefaultEvent` returning `{ taskType: 'cogs', bufferBefore: 30, bufferAfter: 60, color: '#239a21' }` so newly drag-created events get a default icon, buffer times, and color.

## 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-angular.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 angular
   ```

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

   ```
   npm install
   ```

6. Run the project:

   ```
   ng serve
   ```

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

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

## Related demos

- Next: [Custom Cell Content](https://demo.mobiscroll.com/angular/timeline/dynamic-cell-content-template.md) - Add workload badges, status icons, and a hover quick-add button to each Angular Timeline cell — and cap events per cell.
