Component Library

← Back to gallery

Timeline grouped by period in HTML, CSS and vanilla JS

A copy-paste Timeline grouped by period 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-by-period" data-dcl-scheme="light">
<header><p class="dcl-timeline-by-period-eyebrow">CHANGE LOG</p><h3>Repository handover</h3></header><div class="dcl-timeline-by-period-periods"><section class="dcl-timeline-by-period-well"><h4>Discovery</h4><ol><li><time datetime="2026-03-03">3 Mar</time> · Received asset list</li><li><time datetime="2026-03-06">6 Mar</time> · Mapped file ownership</li></ol></section><section class="dcl-timeline-by-period-well"><h4>Transfer</h4><ol><li><time datetime="2026-03-12">12 Mar</time> · Verified first archive</li><li><time datetime="2026-03-19">19 Mar</time> · Transferred publishing access</li></ol></section><section class="dcl-timeline-by-period-well"><h4>Follow-up</h4><ol><li><time datetime="2026-03-28">28 Mar</time> · Checked redirect list</li></ol></section></div>
<script>
(() => {
  const root = document.currentScript.closest(".dcl-timeline-by-period");
  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-by-period, .dcl-timeline-by-period * { box-sizing: border-box; }
.dcl-timeline-by-period { 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-by-period h3, .dcl-timeline-by-period h4, .dcl-timeline-by-period p, .dcl-timeline-by-period figure, .dcl-timeline-by-period dl, .dcl-timeline-by-period ul, .dcl-timeline-by-period ol { margin: 0; }
.dcl-timeline-by-period h3 { font-size: 1.18rem; line-height: 1.25; }
.dcl-timeline-by-period header { margin-block-end: .875rem; }
.dcl-timeline-by-period .dcl-timeline-by-period-eyebrow { font-size: .8125rem; font-weight: 700; letter-spacing: .06em; }
.dcl-timeline-by-period .dcl-timeline-by-period-well { padding: .7rem .8rem; border: 1px solid; border-radius: .55rem; }
.dcl-timeline-by-period .dcl-timeline-by-period-muted { font-size: .875rem; }
.dcl-timeline-by-period .dcl-timeline-by-period-row { display: flex; gap: .55rem .8rem; align-items: center; flex-wrap: wrap; }
.dcl-timeline-by-period .dcl-timeline-by-period-grid { display: grid; gap: .65rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.dcl-timeline-by-period dt { font-size: .875rem; font-weight: 650; }
.dcl-timeline-by-period dd { margin: 0; }
.dcl-timeline-by-period .dcl-timeline-by-period-value { font-size: clamp(1.35rem, 5vw, 1.9rem); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dcl-timeline-by-period button, .dcl-timeline-by-period summary, .dcl-timeline-by-period input { font: inherit; }
.dcl-timeline-by-period button, .dcl-timeline-by-period summary { min-height: 2.75rem; cursor: pointer; }
.dcl-timeline-by-period button { padding: .35rem .7rem; border: 1px solid; border-radius: .4rem; }
.dcl-timeline-by-period button:active { transform: translateY(1px); }
.dcl-timeline-by-period button:disabled { cursor: default; border-style: dashed; }
.dcl-timeline-by-period [hidden] { display: none; }
.dcl-timeline-by-period-periods { display:grid; gap:.55rem; } .dcl-timeline-by-period ol { padding-inline-start:1.2em; } .dcl-timeline-by-period time { font-variant-numeric:tabular-nums; font-size:.875rem; }
.dcl-timeline-by-period[data-dcl-scheme="light"] { color: #11292f; background-color: #ffffff; border-color: #697f84; color-scheme: light; }
.dcl-timeline-by-period[data-dcl-scheme="light"] .dcl-timeline-by-period-muted, .dcl-timeline-by-period[data-dcl-scheme="light"] .dcl-timeline-by-period-eyebrow { color: #405a60; }
.dcl-timeline-by-period[data-dcl-scheme="light"] .dcl-timeline-by-period-well, .dcl-timeline-by-period[data-dcl-scheme="light"] button, .dcl-timeline-by-period[data-dcl-scheme="light"] kbd { color: #11292f; background-color: #e4edef; border-color: #697f84; }
.dcl-timeline-by-period[data-dcl-scheme="light"] .dcl-timeline-by-period-accent, .dcl-timeline-by-period[data-dcl-scheme="light"] button:hover { color: #ffffff; background-color: #00535a; border-color: #00535a; }
.dcl-timeline-by-period[data-dcl-scheme="light"] :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.dcl-timeline-by-period[data-dcl-scheme="light"] meter, .dcl-timeline-by-period[data-dcl-scheme="light"] progress, .dcl-timeline-by-period[data-dcl-scheme="light"] input { accent-color: #00535a; }

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

When to use

Use to group tightly related events under short phases or periods. Keep both the phases and their events in chronological order.

Avoid

Do not hide exact dates behind phase names.

Accessibility

Headings identify phase boundaries. Each ordered list retains date and event information. Main text contrast is 15.2:1 in light and 13.1:1 in dark.

Was this useful? Send feedback.