Component Library

← Back to gallery

Timeline with event details in HTML, CSS and vanilla JS

A copy-paste Timeline with event details in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.

Category: Data display · Tags: timeline, data-display, responsive

Live preview

Source (copy-ready)

<div class="dcl-timeline-expanded-history" data-dcl-scheme="light">
<header><p class="dcl-timeline-expanded-history-eyebrow">CASE HISTORY</p><h3>Permit review</h3></header><ol class="dcl-timeline-expanded-history-events"><li><details open><summary><time datetime="2026-03-05">5 Mar</time> · Received</summary><p>The application included the site plan and access notes.</p></details></li><li><details><summary><time datetime="2026-03-12">12 Mar</time> · Reviewed</summary><p>The reviewer requested a revised map showing the delivery entrance.</p></details></li><li><details><summary><time datetime="2026-03-20">20 Mar</time> · Approved</summary><p>Use the March revision when scheduling delivery.</p></details></li></ol>
<script>
(() => {
  const root = document.currentScript.closest(".dcl-timeline-expanded-history");
  const preference = matchMedia("(prefers-color-scheme: dark)");
  function setScheme() { root.dataset.dclScheme = preference.matches ? "dark" : "light"; }
  preference.addEventListener("change", setScheme);
  setScheme();
})();
</script>
</div>
<style>
.dcl-timeline-expanded-history, .dcl-timeline-expanded-history * { box-sizing: border-box; }
.dcl-timeline-expanded-history { max-inline-size: 44rem; margin-inline: auto; padding: clamp(.875rem, 4vw, 1.5rem); border: 1px solid; border-radius: .75rem; font: 1rem/1.5 system-ui, sans-serif; overflow-wrap: anywhere; }
.dcl-timeline-expanded-history h3, .dcl-timeline-expanded-history h4, .dcl-timeline-expanded-history p, .dcl-timeline-expanded-history figure, .dcl-timeline-expanded-history dl, .dcl-timeline-expanded-history ul, .dcl-timeline-expanded-history ol { margin: 0; }
.dcl-timeline-expanded-history h3 { font-size: 1.18rem; line-height: 1.25; }
.dcl-timeline-expanded-history header { margin-block-end: .875rem; }
.dcl-timeline-expanded-history .dcl-timeline-expanded-history-eyebrow { font-size: .8125rem; font-weight: 700; letter-spacing: .06em; }
.dcl-timeline-expanded-history .dcl-timeline-expanded-history-well { padding: .7rem .8rem; border: 1px solid; border-radius: .55rem; }
.dcl-timeline-expanded-history .dcl-timeline-expanded-history-muted { font-size: .875rem; }
.dcl-timeline-expanded-history .dcl-timeline-expanded-history-row { display: flex; gap: .55rem .8rem; align-items: center; flex-wrap: wrap; }
.dcl-timeline-expanded-history .dcl-timeline-expanded-history-grid { display: grid; gap: .65rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.dcl-timeline-expanded-history dt { font-size: .875rem; font-weight: 650; }
.dcl-timeline-expanded-history dd { margin: 0; }
.dcl-timeline-expanded-history .dcl-timeline-expanded-history-value { font-size: clamp(1.35rem, 5vw, 1.9rem); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dcl-timeline-expanded-history button, .dcl-timeline-expanded-history summary, .dcl-timeline-expanded-history input { font: inherit; }
.dcl-timeline-expanded-history button, .dcl-timeline-expanded-history summary { min-height: 2.75rem; cursor: pointer; }
.dcl-timeline-expanded-history button { padding: .35rem .7rem; border: 1px solid; border-radius: .4rem; }
.dcl-timeline-expanded-history button:active { transform: translateY(1px); }
.dcl-timeline-expanded-history button:disabled { cursor: default; border-style: dashed; }
.dcl-timeline-expanded-history [hidden] { display: none; }
.dcl-timeline-expanded-history-events { padding-inline-start:1.3em; } .dcl-timeline-expanded-history-events li { border-block-end:1px solid; } .dcl-timeline-expanded-history summary { padding:.55rem .1rem; font-weight:650; } .dcl-timeline-expanded-history summary:hover { text-decoration:underline; } .dcl-timeline-expanded-history details p { margin-block-end:.65rem; }
.dcl-timeline-expanded-history[data-dcl-scheme="light"] { color: #11292f; background-color: #ffffff; border-color: #697f84; color-scheme: light; }
.dcl-timeline-expanded-history[data-dcl-scheme="light"] .dcl-timeline-expanded-history-muted, .dcl-timeline-expanded-history[data-dcl-scheme="light"] .dcl-timeline-expanded-history-eyebrow { color: #405a60; }
.dcl-timeline-expanded-history[data-dcl-scheme="light"] .dcl-timeline-expanded-history-well, .dcl-timeline-expanded-history[data-dcl-scheme="light"] button, .dcl-timeline-expanded-history[data-dcl-scheme="light"] kbd { color: #11292f; background-color: #e4edef; border-color: #697f84; }
.dcl-timeline-expanded-history[data-dcl-scheme="light"] .dcl-timeline-expanded-history-accent, .dcl-timeline-expanded-history[data-dcl-scheme="light"] button:hover { color: #ffffff; background-color: #00535a; border-color: #00535a; }
.dcl-timeline-expanded-history[data-dcl-scheme="light"] :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.dcl-timeline-expanded-history[data-dcl-scheme="light"] meter, .dcl-timeline-expanded-history[data-dcl-scheme="light"] progress, .dcl-timeline-expanded-history[data-dcl-scheme="light"] input { accent-color: #00535a; }

.dcl-timeline-expanded-history[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; border-color: #839fa5; color-scheme: dark; }
.dcl-timeline-expanded-history[data-dcl-scheme="dark"] .dcl-timeline-expanded-history-muted, .dcl-timeline-expanded-history[data-dcl-scheme="dark"] .dcl-timeline-expanded-history-eyebrow { color: #b0c9ce; }
.dcl-timeline-expanded-history[data-dcl-scheme="dark"] .dcl-timeline-expanded-history-well, .dcl-timeline-expanded-history[data-dcl-scheme="dark"] button, .dcl-timeline-expanded-history[data-dcl-scheme="dark"] kbd { color: #eff8f9; background-color: #1c3c44; border-color: #839fa5; }
.dcl-timeline-expanded-history[data-dcl-scheme="dark"] .dcl-timeline-expanded-history-accent, .dcl-timeline-expanded-history[data-dcl-scheme="dark"] button:hover { color: #11292f; background-color: #8fe1da; border-color: #8fe1da; }
.dcl-timeline-expanded-history[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }
.dcl-timeline-expanded-history[data-dcl-scheme="dark"] meter, .dcl-timeline-expanded-history[data-dcl-scheme="dark"] progress, .dcl-timeline-expanded-history[data-dcl-scheme="dark"] input { accent-color: #8fe1da; }
</style>

When to use

Use for a chronology where readers may want the evidence behind individual events. Keep each event name visible when its details are collapsed.

Avoid

Do not bury mandatory decisions or urgent follow-up only in expanded text.

Accessibility

Native summary supports Enter and Space, and communicates expanded state without custom key bindings. Main text contrast is 15.2:1 in light and 13.1:1 in dark.

Was this useful? Send feedback.