Reverse in React Timeline
24 Sep 20266 minutes to read
Use the reverse property to invert the display order of React Timeline items. Setting reverse to true makes the most recent or last item in the data source appear first, which is useful for activity feeds, audit logs, or any timeline where newest items should be prominent.
When the reverse property is enabled, it works seamlessly with all alignment options (Before, After, Alternate, AlternateReverse) and orientations (Horizontal, Vertical).
import * as React from "react";
import * as ReactDOM from 'react-dom/client';
import { TimelineComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-layouts';
function App() {
const careerProgress = [
"Graduated \n Bachelors in Computer Engineering",
"Software Engineering Internship \n ABC Software and Technology",
"Associate Software Engineer \n ABC Software and Technology",
"Software Level 1 Engineer \n XYZ Solutions"
];
return (
<div id='timeline'>
<TimelineComponent align='Before' reverse={true}>
<ItemsDirective>
<ItemDirective content='June 2022' oppositeContent = {careerProgress[0]} />
<ItemDirective content='Aug 2022' oppositeContent = {careerProgress[1]} />
<ItemDirective content='Feb 2023' oppositeContent = {careerProgress[2]} />
<ItemDirective content='Mar 2024' oppositeContent = {careerProgress[3]} />
</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 careerProgress = [
"Graduated \n Bachelors in Computer Engineering",
"Software Engineering Internship \n ABC Software and Technology",
"Associate Software Engineer \n ABC Software and Technology",
"Software Level 1 Engineer \n XYZ Solutions"
];
return (
<div id='timeline'>
<TimelineComponent align='Before' reverse={true}>
<ItemsDirective>
<ItemDirective content='June 2022' oppositeContent = {careerProgress[0]} />
<ItemDirective content='Aug 2022' oppositeContent = {careerProgress[1]} />
<ItemDirective content='Feb 2023' oppositeContent = {careerProgress[2]} />
<ItemDirective content='Mar 2024' oppositeContent = {careerProgress[3]} />
</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: 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>