Skip to content

Theme

React-Chrono provides extensive theme customization capabilities through the theme object. You can customize colors for all visual elements including cards, icons, buttons, interactive states, and effects to match your brand or design system.

The library provides default themes optimized for both light and dark modes. All theme properties are optional and will fall back to sensible defaults.

Core Theme Properties

Card Colors

PropertyTypeDefault (Light)Description
cardBgColorstring#ffffffBackground color of timeline cards
cardDetailsBackGroundstring#ffffffBackground color of the card details section
cardDetailsColorstring#374151Text color for card details/content
cardMediaBgColorstring#f8fafcBackground color for media elements in cards
cardSubtitleColorstring#6b7280Color of card subtitles
cardTitleColorstring#007FFFColor of card titles

Primary & Secondary Colors

PropertyTypeDefault (Light)Description
primarystring#007FFFPrimary brand color used throughout the timeline
secondarystring#ffdf00Secondary accent color

Icon Colors

PropertyTypeDefault (Light)Description
iconBackgroundColorstring#007FFFBackground color of timeline point icons
iconColorstring#007FFFColor of icons and icon elements

Timeline Title Colors

PropertyTypeDefault (Light)Description
titleColorstring#007FFFColor of timeline item titles
titleColorActivestring#007FFFColor of active timeline item titles

Toolbar Colors

PropertyTypeDefault (Light)Description
toolbarBgColorstring#f1f5f9Background color of the timeline toolbar
toolbarBtnBgColorstring#ffffffBackground color of toolbar buttons
toolbarTextColorstring#1e293bText color for toolbar elements

Interactive Button States

PropertyTypeDefault (Light)Description
buttonHoverBgColorstring#e2e8f0Background color when hovering over buttons
buttonActiveBgColorstring#007FFFBackground color for active/pressed buttons
buttonActiveIconColorstring#ffffffIcon color for active buttons

Border Colors

PropertyTypeDefault (Light)Description
buttonBorderColorstring#e2e8f0Border color for buttons and interactive elements
buttonHoverBorderColorstring#007FFFBorder color when hovering over buttons
buttonActiveBorderColorstring#007FFFBorder color for active buttons

Visual Effects

PropertyTypeDefault (Light)Description
shadowColorstringrgba(0, 0, 0, 0.1)Color for shadows and depth effects
glowColorstringrgba(0, 127, 255, 0.2)Color for glow effects on focus/hover
searchHighlightColorstringrgba(0, 127, 255, 0.2)Background color for search result highlights

Nested Timeline Cards

PropertyTypeDefault (Light)Description
nestedCardBgColorstring#f8fafcBackground color for nested timeline cards
nestedCardDetailsBackGroundstring#f8fafcBackground color for nested card details
nestedCardDetailsColorstring#374151Text color for nested card details
nestedCardSubtitleColorstring#6b7280Subtitle color for nested cards
nestedCardTitleColorstring#1f2937Title color for nested cards

Dark Mode Toggle

PropertyTypeDefault (Light)Description
darkToggleActiveBgColorstring#007FFFBackground color for active dark mode toggle
darkToggleActiveIconColorstring#ffffffIcon color for active dark mode toggle
darkToggleActiveBorderColorstring#007FFFBorder color for active dark mode toggle
darkToggleGlowColorstringrgba(0, 127, 255, 0.2)Glow effect color for dark mode toggle

Layout Colors

PropertyTypeDefault (Light)Description
timelineBgColorstring#ffffffBackground color for the entire timeline container
textColorstringinheritGeneral text color (fallback)
detailsColorstring#374151Color for detail text elements

Dark Mode Support

React-Chrono includes built-in dark mode themes with optimized colors for better contrast and readability in dark environments. The dark theme uses darker backgrounds with lighter text colors:

jsx
// Dark mode is automatically applied when enableDarkToggle is true
<Chrono
  items={items}
  enableDarkToggle={true}
  theme={{
    // Your custom theme properties will be merged with dark mode defaults
    primary: "#3b82f6",
    secondary: "#fbbf24",
  }}
/>

Example Usage

Basic Customization

jsx
<Chrono
  items={items}
  theme={{
    primary: "#2563eb",
    secondary: "#7c3aed",
    cardBgColor: "#f8fafc",
    cardTitleColor: "#1e293b",
    titleColor: "#2563eb",
    titleColorActive: "#7c3aed",
  }}
/>

Advanced Brand Customization

jsx
<Chrono
  items={items}
  theme={{
    // Brand colors
    primary: "#2d3748",
    secondary: "#ed8936",
    
    // Card styling
    cardBgColor: "#ffffff",
    cardTitleColor: "#2d3748",
    cardSubtitleColor: "#4a5568",
    cardDetailsColor: "#718096",
    
    // Interactive states
    buttonHoverBgColor: "#e2e8f0",
    buttonActiveBgColor: "#ed8936",
    buttonActiveIconColor: "#ffffff",
    
    // Effects
    shadowColor: "rgba(0, 0, 0, 0.1)",
    glowColor: "rgba(237, 137, 54, 0.3)",
  }}
/>

High Contrast Theme

jsx
<Chrono
  items={items}
  theme={{
    cardBgColor: "#000000",
    cardTitleColor: "#ffffff",
    cardDetailsColor: "#ffffff",
    iconColor: "#00ff00",
    buttonActiveBgColor: "#ffff00",
    buttonActiveIconColor: "#000000",
    shadowColor: "rgba(255, 255, 255, 0.3)",
  }}
/>

Theme Inheritance

Custom theme properties are merged with the default theme, so you only need to specify the properties you want to customize. The library automatically handles:

  • Color fallbacks: If a specific color isn't provided, sensible defaults are used
  • Dark mode integration: Your custom colors work seamlessly with the built-in dark mode toggle
  • Accessibility: Default themes maintain WCAG AA contrast ratios

Best Practices

  1. Maintain contrast ratios: Ensure sufficient contrast between text and background colors for accessibility
  2. Test in both modes: Verify your custom theme works well in both light and dark modes
  3. Use semantic colors: Consider the meaning of each color property and use appropriate values
  4. Brand consistency: Use your brand's color palette to create a cohesive look

Released under the MIT License.