Convert Figma logo to code with AI

prabhuignoto logoreact-chrono

Modern Timeline Component for React

4,157
227
4,157
17

Top Related Projects

13,845

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries

26,169

Redefined chart library built with React and D3

11,209

A collection of composable React components for building interactive data visualizations

20,376

🐯 visx | visualization components

📊 Interactive JavaScript Charts built on SVG

Quick Overview

React-Chrono is a flexible and customizable timeline component for React applications. It allows developers to create interactive timelines with various layouts, themes, and customization options, making it suitable for displaying historical events, project milestones, or any chronological data.

Pros

  • Highly customizable with multiple layout options (vertical, horizontal, tree)
  • Supports various media types (images, videos, cards) within timeline items
  • Responsive design and mobile-friendly
  • Well-documented with TypeScript support

Cons

  • Limited animation options for timeline transitions
  • May require additional styling for complex use cases
  • Large bundle size compared to simpler timeline libraries
  • Limited built-in accessibility features

Code Examples

  1. Basic timeline setup:
import { Chrono } from "react-chrono";

const items = [
  { title: "May 1940", cardTitle: "Dunkirk", cardSubtitle: "Men of the British Expeditionary Force (BEF) wade out to a destroyer during the evacuation from Dunkirk." },
  { title: "25 July 1940", cardTitle: "The Battle of Britain", cardSubtitle: "RAF Spitfire pilots scramble for their planes" },
  { title: "June 1941", cardTitle: "Operation Barbarossa", cardSubtitle: "A column of Red Army prisoners of war taken during the first days of the German invasion" },
];

const Timeline = () => (
  <Chrono items={items} mode="VERTICAL" />
);
  1. Customizing timeline appearance:
<Chrono
  items={items}
  mode="HORIZONTAL"
  theme={{
    primary: "#0077B6",
    secondary: "#48CAE4",
    cardBgColor: "#CAF0F8",
    titleColor: "#03045E",
  }}
  cardHeight={200}
  slideItemDuration={1000}
/>
  1. Adding media to timeline items:
const itemsWithMedia = [
  {
    title: "1969",
    cardTitle: "Moon Landing",
    cardSubtitle: "Neil Armstrong becomes the first human to step on the Moon",
    media: {
      type: "IMAGE",
      source: {
        url: "https://example.com/moon-landing.jpg"
      }
    }
  },
  // ... more items
];

<Chrono items={itemsWithMedia} mode="VERTICAL_ALTERNATING" />

Getting Started

  1. Install the package:

    npm install react-chrono
    
  2. Import and use in your React component:

    import React from 'react';
    import { Chrono } from 'react-chrono';
    
    const MyTimeline = () => {
      const items = [
        { title: "2020", cardTitle: "Event 1", cardSubtitle: "Event 1 Description" },
        { title: "2021", cardTitle: "Event 2", cardSubtitle: "Event 2 Description" },
        { title: "2022", cardTitle: "Event 3", cardSubtitle: "Event 3 Description" },
      ];
    
      return (
        <div style={{ width: '500px', height: '400px' }}>
          <Chrono items={items} mode="VERTICAL" />
        </div>
      );
    };
    
    export default MyTimeline;
    

Competitor Comparisons

13,845

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries

Pros of nivo

  • Offers a wide variety of chart types and data visualization options
  • Highly customizable with extensive documentation and examples
  • Built with React and D3, providing powerful and interactive visualizations

Cons of nivo

  • Steeper learning curve due to its extensive feature set
  • May be overkill for simple timeline or chronological data representation
  • Larger bundle size compared to more focused libraries

Code Comparison

nivo example (Bar Chart):

import { ResponsiveBar } from '@nivo/bar'

const MyChart = () => (
  <ResponsiveBar
    data={data}
    keys={['hot dog', 'burger', 'sandwich', 'kebab', 'fries', 'donut']}
    indexBy="country"
    margin={{ top: 50, right: 130, bottom: 50, left: 60 }}
    padding={0.3}
    colors={{ scheme: 'nivo' }}
  />
)

react-chrono example (Timeline):

import { Chrono } from "react-chrono";

const MyTimeline = () => (
  <Chrono
    items={items}
    mode="VERTICAL"
    slideShow
    slideItemDuration={2000}
    slideShowInterval={5000}
  />
)

While nivo provides a comprehensive solution for various data visualizations, react-chrono focuses specifically on timeline representations. nivo offers more flexibility but requires more setup, whereas react-chrono provides a simpler API for creating timelines quickly.

26,169

Redefined chart library built with React and D3

Pros of recharts

  • More comprehensive charting library with various chart types (line, bar, area, etc.)
  • Higher GitHub stars and wider community adoption
  • Extensive documentation and examples

Cons of recharts

  • Steeper learning curve due to more complex API
  • Larger bundle size, which may impact performance for simpler use cases

Code Comparison

react-chrono (Timeline component):

<Chrono items={items} mode="VERTICAL" />

recharts (LineChart component):

<LineChart width={400} height={400} data={data}>
  <Line type="monotone" dataKey="uv" stroke="#8884d8" />
  <CartesianGrid stroke="#ccc" />
  <XAxis dataKey="name" />
  <YAxis />
</LineChart>

Summary

recharts is a more feature-rich charting library suitable for various data visualization needs, while react-chrono focuses specifically on timeline components. recharts offers greater flexibility but may be overkill for simple timeline requirements. react-chrono provides a more straightforward API for timeline creation but lacks the versatility of recharts for other chart types.

11,209

A collection of composable React components for building interactive data visualizations

Pros of Victory

  • Comprehensive charting library with a wide range of chart types
  • Highly customizable with extensive API and theming options
  • Strong community support and regular updates

Cons of Victory

  • Steeper learning curve due to its extensive features
  • Larger bundle size compared to more focused libraries
  • May be overkill for simple timeline or chronological visualizations

Code Comparison

Victory (creating a simple line chart):

import { VictoryChart, VictoryLine, VictoryAxis } from 'victory';

<VictoryChart>
  <VictoryLine data={[{x: 1, y: 2}, {x: 2, y: 3}, {x: 3, y: 5}]} />
  <VictoryAxis />
</VictoryChart>

react-chrono (creating a simple timeline):

import { Chrono } from "react-chrono";

<Chrono items={[
  { title: "May 1940", cardTitle: "Dunkirk", cardSubtitle: "Men of the British Expeditionary Force (BEF) wade out to..." },
  { title: "May 1940", cardTitle: "Dunkirk", cardSubtitle: "Men of the British Expeditionary Force (BEF) wade out to..." },
]} />

While Victory offers a comprehensive solution for various chart types, react-chrono provides a more focused and easier-to-use option for timeline visualizations. Victory's flexibility comes at the cost of complexity, whereas react-chrono offers a simpler API for its specific use case.

20,376

🐯 visx | visualization components

Pros of visx

  • More comprehensive data visualization library with a wide range of chart types and components
  • Highly customizable and flexible, allowing for complex and interactive visualizations
  • Backed by Airbnb, with a larger community and more frequent updates

Cons of visx

  • Steeper learning curve due to its extensive API and lower-level components
  • Requires more setup and configuration for basic use cases
  • May be overkill for simple timeline or chronological visualizations

Code Comparison

react-chrono:

<Chrono items={items} mode="VERTICAL" />

visx:

<XYChart height={300} xScale={{ type: 'band' }} yScale={{ type: 'linear' }}>
  <BarSeries dataKey="bar" data={data} />
  <Axis orientation="bottom" />
  <Axis orientation="left" />
</XYChart>

Summary

react-chrono is a specialized library for creating timeline components, offering a simpler API and easier implementation for chronological data visualization. visx, on the other hand, is a more powerful and versatile data visualization library that can be used for various chart types, including timelines. While react-chrono is more suitable for quick timeline implementations, visx provides greater flexibility and customization options for complex data visualizations across different chart types.

📊 Interactive JavaScript Charts built on SVG

Pros of ApexCharts.js

  • Offers a wide variety of chart types and customization options
  • Supports responsive and interactive charts out of the box
  • Has extensive documentation and a large community

Cons of ApexCharts.js

  • Larger file size compared to React Chrono
  • May have a steeper learning curve for complex visualizations
  • Not specifically designed for timeline or chronological data

Code Comparison

React Chrono:

<Chrono items={items} mode="VERTICAL" />

ApexCharts.js:

var options = {
  chart: { type: 'line' },
  series: [{ data: [30, 40, 35, 50, 49, 60, 70] }],
  xaxis: { categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997] }
};
var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();

While React Chrono is specifically designed for creating timelines with a simple API, ApexCharts.js offers more versatility for various chart types but requires more configuration. React Chrono is more focused and easier to use for timeline-specific visualizations, while ApexCharts.js provides broader charting capabilities at the cost of increased complexity.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

React Chrono UI Logo

The Ultimate Timeline Component for React Applications

Build stunning, interactive timelines with rich media support, accessibility-first design, and comprehensive customization options

npm version npm downloads npm bundle size License TypeScript

Build Status Coverage Status Codacy Badge Known Vulnerabilities

styled with PrettierReact


Timeline Modes & Layouts

4 Flexible Modes • Nested Timelines • Responsive

Rich Media & Content

Images • Videos • YouTube • Custom Components

Theming & Customization

Dark Mode • 36 Properties • Google Fonts

Developer Experience

TypeScript • Zero Dependencies • Vanilla Extract

User Experience

Slideshow • Search • Keyboard Navigation

Accessibility & i18n

WCAG AA • 60+ i18n Elements • Mobile First


Table of Contents

Quick Start
Timeline Modes
Features
API & Documentation
Development

Quick Start

⚡ Get started in 30 seconds

Installation

# Using npm
npm install react-chrono

# Using yarn
yarn add react-chrono

# Using bun (recommended)
bun add react-chrono

Requirements: React 18.2+ or 19+ | Node.js 22+ | TypeScript 4.0+ (optional) | Modern browsers

Basic Usage

Minimal Setup - Your First Timeline

import { Chrono } from 'react-chrono';

const items = [
  { title: 'May 1940', cardTitle: 'Dunkirk', cardDetailedText: 'Allied evacuation from France' },
  { title: 'June 1944', cardTitle: 'D-Day', cardDetailedText: 'Normandy invasion begins' }
];

<Chrono items={items} />

Result Preview:

Vertical Timeline Mode

Common Configurations

Horizontal Timeline with Custom Theme
<Chrono
  items={items}
  mode="horizontal"
  theme={{ primary: '#0079e6', cardBgColor: '#f5f5f5' }}
/>
Vertical Timeline with Media
const items = [
  {
    title: 'January 2024',
    cardTitle: 'Product Launch',
    cardDetailedText: 'Released version 3.0 with new features',
    media: {
      type: 'IMAGE',
      source: { url: 'https://example.com/launch.jpg' },
      name: 'Product launch event'
    }
  }
];

<Chrono items={items} mode="vertical" />
Alternating Timeline with Slideshow
<Chrono
  items={items}
  mode="alternating"
  animation={{
    slideshow: {
      enabled: true,
      duration: 3000,
      type: 'fade'
    }
  }}
/>

Advanced Configuration with Grouped API ✨

The new grouped API organizes configuration into logical sections:

<Chrono
  items={items}
  mode="alternating"
  
  layout={{
    cardWidth: 450,
    cardHeight: 'auto',  // Automatic sizing based on content
    responsive: { enabled: true, breakpoint: 768 }
  }}
  
  content={{
    alignment: {
      horizontal: 'center',
      vertical: 'center'
    }
  }}
  
  interaction={{
    keyboardNavigation: true,
    pointClick: true,
    autoScroll: true
  }}
  
  display={{
    borderless: false,
    toolbar: { enabled: true, sticky: true }
  }}
  
  animation={{
    slideshow: { enabled: true, duration: 4000, type: 'fade' }
  }}
  
  theme={{
    primary: '#0079e6',
    cardBgColor: '#ffffff',
    cardTitleColor: '#1f2937'
  }}
/>

💡 Try it live: Browse interactive examples in Storybook


Visual Examples

See React Chrono in action

Vertical Mode Scroll-friendly chronological flow

Vertical Timeline Mode

Alternating Mode Cards alternate left and right

Alternating Timeline Mode

Dark Mode Complete theme control

Dark Mode Timeline

Horizontal All Dashboard view showing complete timeline

Timeline Modes

Timeline with Media Embed YouTube videos and images

Timeline with Media


Timeline Modes

React Chrono offers four layout modes, each optimized for specific use cases:

ModeBest ForVisual Style
VerticalFeeds, news timelines, mobile experiencesTop-to-bottom scroll-friendly layout
HorizontalHistorical narratives, project phasesLeft-to-right chronological flow
AlternatingPortfolios, company milestonesCards alternate left and right of central axis
Horizontal AllDashboards, comparisonsShows all timeline items at once

Use Case Guide

📱 Mobile-First Content → Use Vertical Mode

Perfect for feeds, news timelines, and mobile experiences where scrolling is natural.

<Chrono items={items} mode="vertical" />
📊 Historical Narratives → Use Horizontal Mode

Ideal for historical narratives and project phases where the journey matters.

<Chrono items={items} mode="horizontal" />
💼 Portfolios & Milestones → Use Alternating Mode

Great for portfolios and company milestones with balanced visual rhythm.

<Chrono items={items} mode="alternating" />
📈 Dashboards & Comparisons → Use Horizontal All

Perfect for dashboards, comparisons, and seeing the complete picture at once.

<Chrono items={items} mode="horizontal-all" />

Key Features

Rich Media Integration

Smart Loading & Performance

  • Images load only when entering viewport (intersection observers)
  • Videos auto-play when timeline items become active
  • Automatic responsive sizing and buffering
  • Built-in accessibility attributes
const items = [{
  title: 'Event',
  cardTitle: 'Media Example',
  media: {
    type: 'IMAGE',
    source: { url: 'image.jpg' }
  }
}];

<Chrono items={items} />

Interactive Features

Slideshow Mode Auto-playing presentations with customizable durations, transition effects, and progress indicators.

Keyboard Navigation Full accessibility with arrow keys, Home/End for quick jumps, Escape for modals.

Real-time Search Instantly highlights matching content across titles, descriptions, and metadata.

<Chrono
  items={items}
  animation={{
    slideshow: {
      enabled: true,
      duration: 3000,
      type: 'fade'
    }
  }}
  interaction={{
    keyboardNavigation: true
  }}
  display={{
    toolbar: {
      enabled: true,
      search: { enabled: true }
    }
  }}
/>

Theming & Customization

Complete Theme Control

  • 36 customizable theme properties
  • Dark mode with dedicated properties
  • Google Fonts integration with automatic loading
  • Per-element typography customization
<Chrono
  items={items}
  theme={{
    primary: '#0079e6',
    cardBgColor: '#ffffff',
    cardTitleColor: '#1f2937',
    timelineBgColor: '#f5f5f5'
  }}
  darkMode={{ enabled: true }}
/>

Internationalization

Global Ready

  • 60+ configurable text elements
  • Intelligent fallbacks
  • Template strings with variable interpolation
  • Full type safety
<Chrono
  items={items}
  i18n={{
    texts: {
      navigation: {
        first: 'Premier élément',
        next: 'Suivant',
        previous: 'Précédent'
      },
      search: {
        placeholder: 'Rechercher',
        noResults: 'Aucun résultat'
      }
    }
  }}
/>

Advanced Features

Nested Timelines Create multi-level narratives where major events contain detailed sub-timelines.

Custom Components Embed fully interactive React components within timeline cards.

Responsive Design Fundamentally adapts to each device with smart font sizing and spacing.

// Nested timeline example
const items = [{
  title: 'Major Event',
  cardTitle: 'Period',
  children: <Chrono items={subItems} />
}];

<Chrono items={items} />

Essential Props

React Chrono requires minimal configuration to get started:

PropertyTypeDescription
itemsTimelineItem[]Array of timeline data
modestringLayout mode: 'horizontal' | 'vertical' | 'alternating' | 'horizontal-all'
themeThemeCustomize colors and appearance

📚 Need complete prop documentation? See our comprehensive Props Reference


Migration from v2 to v3

React Chrono v3.0 maintains full backward compatibility - your existing v2.x code will work without changes. However, we recommend migrating to the new grouped API for better maintainability and IDE support.

Quick Migration

v2.x (still works):

<Chrono 
  items={items}
  cardWidth={400}
  disableNavOnKey={false}
  borderLessCards={true}
  slideShow={true}
  slideItemDuration={3000}
  mediaHeight={400}
/>

v3.0 (recommended):

<Chrono
  items={items}
  layout={{ cardWidth: 400 }}
  interaction={{ keyboardNavigation: true }}
  display={{ borderless: true }}
  animation={{
    slideshow: {
      enabled: true,
      duration: 3000
    }
  }}
  media={{ height: 400 }}
/>

Common Prop Mappings

v2.x Propv3.0 Prop
borderLessCardsdisplay.borderless
disableNavOnKeyinteraction.keyboardNavigation (inverted)
timelinePointDimensionlayout.pointSize
slideShowanimation.slideshow.enabled
slideItemDurationanimation.slideshow.duration
mediaHeightmedia.height
parseDetailsAsHTMLcontent.allowHTML
disableToolbardisplay.toolbar.enabled (inverted)

What's New in v3.0

  • 🎨 Grouped API - Props organized into logical groups (layout, interaction, content, display, media, animation)
  • ⚡ Zero-runtime CSS - Migrated to Vanilla Extract for better performance
  • 🌐 i18n Support - 60+ configurable text elements
  • 🎭 Google Fonts - Per-element font control
  • 🖼️ Fullscreen Mode - Cross-browser fullscreen support
  • 📌 Sticky Toolbar - Always-accessible controls

🔗 Complete migration guide: Props Reference


What's New in v3.0

🎉 Major updates and improvements

Key Highlights

🏗️ Grouped API Props organized into logical groups (layout, interaction, content, display, media, animation, style, accessibility, i18n) for better IDE autocomplete

⚡ Performance Complete migration to Vanilla Extract for zero-runtime CSS and improved performance

🎨 New Features Auto card height, content alignment, Google Fonts, i18n support, fullscreen mode, and more

📋 Full changelog: See CHANGELOG.md for complete details

🔄 Backward Compatible: All v2.x props remain fully supported with automatic mapping to the new grouped API


Development Setup

Prerequisites

  • Node.js 22+
  • bun (recommended) or npm

Initial Setup

# Clone the repository
git clone https://github.com/prabhuignoto/react-chrono.git
cd react-chrono

# Install dependencies
bun install

Development Commands

# Start development server with hot reload
bun run dev

# Build for production
bun run build

# Run unit tests
bun test

# Lint and format code
bun run clean

Testing Framework

React Chrono uses a comprehensive testing approach:

  • Unit Tests: Vitest with @testing-library/react

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contribution Checklist

  • Fork the repo and create a feature branch
  • Write tests for new features
  • Ensure all tests pass: bun run find-bugs
  • Follow our code style: bun run clean
  • Update documentation if needed
  • Submit a pull request

Built With Modern Technologies

Core Technologies

Development Tools


Support the Project

Love React Chrono? Help us grow!

⭐ Star on GitHub | 🐦 Follow on Twitter | 🐛 Report Issues

Made with ❤️ by Prabhu Murthy and contributors


NPM DownloadsLast 30 Days