Items in React Timeline

24 Sep 202624 minutes to read

The React Timeline items can be configured using the ItemDirective tag. Each item supports multiple configuration options including content, oppositeContent, dotCss, disabled, and cssClass properties to create rich, interactive timeline experiences.

Adding content

Define the primary content for React Timeline items using the content property. This property supports both string values and templated content to allow flexible content presentation.

String content

Define simple text content for React Timeline items using string values.

import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Shipped' />
                    <ItemDirective content='Departed' />
                    <ItemDirective content='Arrived' />
                    <ItemDirective content='Out for Delivery' />
                </ItemsDirective>
            </TimelineComponent>
         </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Shipped' />
                    <ItemDirective content='Departed' />
                    <ItemDirective content='Arrived' />
                    <ItemDirective content='Out for Delivery' />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
/* Represents the styles for loader */
#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}

#timeline {
  height: 330px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion EJ2 React Timeline Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element' style="margin-top: 30px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Templated content

Create rich, dynamic content for React Timeline items by specifying template selectors that reference HTML elements with custom markup and styling.

import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    
  const templateContents = [
    { title: 'Shipped', description: 'Package details received', info: '- Awaiting dispatch' },
    { title: 'Departed', description: 'In-transit', info: '(International warehouse)' },
    { title: 'Arrived', description: 'Package arrived at nearest hub', info: '(New York - US)' }
];

const contentTemplate = (data) => (
  <div className="content-container">
      <div className="title">
          {data.title}
      </div>
      <span className="description">
          {data.description}
      </span>
      <div className="info">
          {data.info}
      </div>
  </div>
);

return (
  <div className="container">
      <TimelineComponent id="timeline">
          <ItemsDirective>
              {templateContents.map((item, index) => (
                  <ItemDirective key={index} content={() => contentTemplate(item)}/>
              ))}
              <ItemDirective content="Out for Delivery" />
          </ItemsDirective>
      </TimelineComponent>
  </div>
);

}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    
  const templateContents = [
    { title: 'Shipped', description: 'Package details received', info: '- Awaiting dispatch' },
    { title: 'Departed', description: 'In-transit', info: '(International warehouse)' },
    { title: 'Arrived', description: 'Package arrived at nearest hub', info: '(New York - US)' }
];

const contentTemplate = (data: any) => (
  <div className="content-container">
      <div className="title">
          {data.title}
      </div>
      <span className="description">
          {data.description}
      </span>
      <div className="info">
          {data.info}
      </div>
  </div>
);

return (
  <div className="container">
      <TimelineComponent id="timeline">
          <ItemsDirective>
              {templateContents.map((item, index) => (
                  <ItemDirective key={index} content={() => contentTemplate(item)}/>
              ))}
              <ItemDirective content="Out for Delivery" />
          </ItemsDirective>
      </TimelineComponent>
  </div>
);

}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
/* Represents the styles for loader */
#loader {
    color: #008cff;
    height: 40px;
    left: 45%;
    position: absolute;
    top: 45%;
    width: 30%;
  }

.content-container {
    position: relative;
    width: 180px;
    padding: 10px;
    margin-left: 5px;
    box-shadow: rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 1px;
    background-color: ghostwhite;
}

.content-container::before {
    content: '';
    position: absolute;
    left: -8px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 8px solid silver;
}

.content-container .title {
    font-size: 16px;
}

.content-container .description {
    color: #999999;
    font-size: 12px;
}

.content-container .info {
    color: #999999;
    font-size: 10px;
}

.container {
  height: 330px;
  margin-top: 30px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion EJ2 React Timeline Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element' style="margin-top: 30px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Adding opposite content

Enhance React Timeline items with supplementary information using the oppositeContent property. This content appears on the opposite side of the timeline from the main content and is ideal for dates, metadata, or secondary details. Like the content property, oppositeContent accepts both string and template values.

String opposite content

Define simple text as opposite content using string values.

import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Breakfast' oppositeContent='8:00 AM' />
                    <ItemDirective content='Lunch' oppositeContent='1:00 PM' />
                    <ItemDirective content='Dinner' oppositeContent='8:00 PM' />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Breakfast' oppositeContent='8:00 AM' />
                    <ItemDirective content='Lunch' oppositeContent='1:00 PM' />
                    <ItemDirective content='Dinner' oppositeContent='8:00 PM' />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
/* Represents the styles for loader */
#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}

#timeline {
  height: 330px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion EJ2 React Timeline Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element' style="margin-top: 30px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Templated opposite content

Create rich, dynamic opposite content for React Timeline items using templates to display structured information such as time labels and category tags.

import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    const items = [
        { content: 'Breakfast', time: '8:00 AM', label: 'Morning' },
        { content: 'Lunch', time: '1:00 PM', label: 'Afternoon' },
        { content: 'Snacks', time: '4:30 PM', label: 'Evening' },
        { content: 'Dinner', time: '8:00 PM', label: 'Night' }
    ];

    const oppositeTemplate = (data) => (
        <div className="opposite-container">
            <span className="time">{data.time}</span>
            <span className="label">{data.label}</span>
        </div>
    );

    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    {items.map((item, index) => (
                        <ItemDirective
                            key={index}
                            content={item.content}
                            oppositeContent={() => oppositeTemplate(item)}
                        />
                    ))}
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(
  document.getElementById('element')
);
root.render(<App />);
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

interface ItemData {
    content: string;
    time: string;
    label: string;
}

function App() {
    const items: ItemData[] = [
        { content: 'Breakfast', time: '8:00 AM', label: 'Morning' },
        { content: 'Lunch', time: '1:00 PM', label: 'Afternoon' },
        { content: 'Snacks', time: '4:30 PM', label: 'Evening' },
        { content: 'Dinner', time: '8:00 PM', label: 'Night' }
    ];

    const oppositeTemplate = (data: ItemData) => (
        <div className="opposite-container">
            <span className="time">{data.time}</span>
            <span className="label">{data.label}</span>
        </div>
    );

    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    {items.map((item, index) => (
                        <ItemDirective
                            key={index}
                            content={item.content}
                            oppositeContent={() => oppositeTemplate(item)}
                        />
                    ))}
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(
  document.getElementById('element')
);
root.render(<App />);
/* Represents the styles for loader */
#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}

.opposite-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.opposite-container .time {
    font-weight: 600;
    font-size: 14px;
}

.opposite-container .label {
    font-size: 11px;
    color: #999999;
}

#timeline {
  height: 330px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion EJ2 React Timeline Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element' style="margin-top: 30px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Customizing dot appearance

Personalize the visual appearance of React Timeline item dots using the dotCss property. This property accepts CSS class names that enable custom styling including icons, background images, colors, and text content.

Adding icons

Apply CSS classes that reference icon fonts or icon libraries to display meaningful icons for each event or milestone.

Adding images

Incorporate custom images as dot backgrounds by defining CSS classes with background-image properties, perfect for displaying avatars, logos, or event-specific imagery.

Adding text

Display short text labels within dots by using CSS classes or template content properties, useful for abbreviations, numbers, or status indicators.

import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Default' />
                    <ItemDirective content='Icon' dotCss='e-icons e-check' />
                    <ItemDirective content='Image' dotCss='custom-image' />
                    <ItemDirective content='Text' dotCss='custom-text' />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Default' />
                    <ItemDirective content='Icon' dotCss='e-icons e-check' />
                    <ItemDirective content='Image' dotCss='custom-image' />
                    <ItemDirective content='Text' dotCss='custom-text' />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
/* Represents the styles for loader */
#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}

.e-dot.custom-image {
  background-image: url(https://ej2.syncfusion.com/demos/src/listview/images/margaret.png);
}

.e-dot.custom-text::before {
  content: 'A';
}

#timeline {
  height: 330px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion EJ2 React Timeline Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element' style="margin-top: 30px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Disabling items

Control item interactivity using the disabled property. When set to true, the item appears visually disabled with reduced opacity and becomes non-interactive. The default value is false.

import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Eat' />
                    <ItemDirective content='Code' />
                    <ItemDirective content='Repeat' disabled={true} />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';

function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Eat' />
                    <ItemDirective content='Code' />
                    <ItemDirective content='Repeat' disabled={true} />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('element'));
root.render(<App />);
/* Represents the styles for loader */
#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}

#timeline {
  height: 330px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion EJ2 React Timeline Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element' style="margin-top: 30px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

CSS class customization

Apply custom styling to individual React Timeline items using the cssClass property. This property accepts CSS class names that enable comprehensive visual customization including colors, fonts, spacing, and layout modifications.

import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';


function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Shipped' cssClass='shipped' />
                    <ItemDirective content='Departed' cssClass='departed' />
                    <ItemDirective content='Arrived' cssClass='arrived' />
                    <ItemDirective content='Out for Delivery' cssClass='out-for-delivery' />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(
  document.getElementById('element')
);
root.render(<App />);
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';


function App() {
    return (
        <div id='timeline'>
            <TimelineComponent>
                <ItemsDirective>
                    <ItemDirective content='Shipped' cssClass='shipped' />
                    <ItemDirective content='Departed' cssClass='departed' />
                    <ItemDirective content='Arrived' cssClass='arrived' />
                    <ItemDirective content='Out for Delivery' cssClass='out-for-delivery' />
                </ItemsDirective>
            </TimelineComponent>
        </div>
    );
}
export default App;
const root = ReactDOM.createRoot(
  document.getElementById('element')
);
root.render(<App />);
/* Represents the styles for loader */
#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}

.e-timeline .e-timeline-item.shipped .e-dot {
  background-color: #8b5cf6;
}

.e-timeline .e-timeline-item.departed .e-dot {
  background-color: #3b82f6;
}

.e-timeline .e-timeline-item.arrived .e-dot {
  background-color: #f59e0b;
}

.e-timeline .e-timeline-item.out-for-delivery .e-dot {
  background-color: #10b981;
}

#timeline {
  height: 350px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion EJ2 React Timeline Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/35.2.12/tailwind3.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='element' style="margin-top: 30px;">
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>