Component Library

← Back to gallery

Ordered checklist with reference rail in HTML, CSS and vanilla JS

A copy-paste Ordered checklist with reference rail in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.

Category: Tables & lists · Tags: checklist, tasks, progress, ordered-list, todo

Live preview

Source (copy-ready)

<section class="dcl-ordered-checklist-support-rail-root" aria-label="Ordered checklist with a reference rail" data-dcl-scheme="light">
<h2>Check a collection before transfer</h2><div class="dcl-ordered-checklist-support-rail-rail"><div class="dcl-ordered-checklist-support-rail-panel"><h3>What you need</h3><ul class="dcl-ordered-checklist-support-rail-stack" role="list"><li><p>A box label list</p></li>
<li><p>An approved destination</p></li>
<li><p>A named recipient</p></li></ul><p role="status">0 of 3 steps complete</p></div>
<ol class="dcl-ordered-checklist-support-rail-stack" role="list"><li><div class="dcl-ordered-checklist-support-rail-border"><label class="dcl-ordered-checklist-support-rail-bar"><input type="checkbox" value="0" > 1. Check identifiers</label><p class="dcl-ordered-checklist-support-rail-muted">Confirm that each box has a unique label.</p></div></li>
<li><div class="dcl-ordered-checklist-support-rail-border"><label class="dcl-ordered-checklist-support-rail-bar"><input type="checkbox" value="1" > 2. Make a working copy</label><p class="dcl-ordered-checklist-support-rail-muted">Keep the original scans unchanged.</p></div></li>
<li><div class="dcl-ordered-checklist-support-rail-border"><label class="dcl-ordered-checklist-support-rail-bar"><input type="checkbox" value="2" > 3. Record the handoff</label><p class="dcl-ordered-checklist-support-rail-muted">Name the recipient and location.</p></div></li></ol></div>
<script>
(() => {
  const root = document.currentScript.closest(".dcl-ordered-checklist-support-rail-root");
  const preference = matchMedia("(prefers-color-scheme: dark)");
  const apply = () => {
    root.dataset.dclScheme = document.documentElement.dataset.theme || (preference.matches ? "dark" : "light");
  };
  preference.addEventListener("change", apply);
  apply();

  const fields = [...root.querySelectorAll("input")];
  const announce = () => {
    const done = fields.filter((field) => field.checked).length;
    root.querySelector('[role="status"]').textContent = done + " of " + fields.length + " steps complete";
    const meter = root.querySelector("progress");
    if (meter) meter.value = done;
  };
  root.addEventListener("change", announce);

})();
</script>
</section>
<style>
.dcl-ordered-checklist-support-rail-root { color: #11292f; background-color: #ffffff; color-scheme: light; }
.dcl-ordered-checklist-support-rail-root .dcl-ordered-checklist-support-rail-panel, .dcl-ordered-checklist-support-rail-root .dcl-ordered-checklist-support-rail-badge,
.dcl-ordered-checklist-support-rail-root button, .dcl-ordered-checklist-support-rail-root input, .dcl-ordered-checklist-support-rail-root select, .dcl-ordered-checklist-support-rail-root summary {
  color: #11292f; background-color: #e4edef; border-color: #697f84;
}
.dcl-ordered-checklist-support-rail-root .dcl-ordered-checklist-support-rail-muted { color: #405a60; }
.dcl-ordered-checklist-support-rail-root button:hover, .dcl-ordered-checklist-support-rail-root button[aria-pressed="true"], .dcl-ordered-checklist-support-rail-root summary:hover {
  color: #ffffff; background-color: #00535a;
}
.dcl-ordered-checklist-support-rail-root a { color: #005c62; }
.dcl-ordered-checklist-support-rail-root :focus-visible { outline: 3px solid #005c62; outline-offset: 3px; }
.dcl-ordered-checklist-support-rail-root { --edge: #697f84; --accent: #00535a; }

.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; color-scheme: dark; }
.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] .dcl-ordered-checklist-support-rail-panel, .dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] .dcl-ordered-checklist-support-rail-badge,
.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] button, .dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] input, .dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] select, .dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] summary {
  color: #eff8f9; background-color: #1c3c44; border-color: #839fa5;
}
.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] .dcl-ordered-checklist-support-rail-muted { color: #b0c9ce; }
.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] button:hover, .dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] button[aria-pressed="true"], .dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] summary:hover {
  color: #11292f; background-color: #8fe1da;
}
.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] a { color: #8fe1da; }
.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 3px; }
.dcl-ordered-checklist-support-rail-root[data-dcl-scheme="dark"] { --edge: #839fa5; --accent: #8fe1da; }

.dcl-ordered-checklist-support-rail-root { display: grid; gap: 1rem; box-sizing: border-box; max-inline-size: 60rem; margin-inline: auto; padding: clamp(0.875rem, 3vw, 2rem);
  border: 1px solid var(--edge); border-radius: 0.75rem; font: 1rem/1.55 system-ui, sans-serif; overflow-wrap: anywhere; }
.dcl-ordered-checklist-support-rail-root * { box-sizing: border-box; min-inline-size: 0; }
.dcl-ordered-checklist-support-rail-root h2, .dcl-ordered-checklist-support-rail-root h3, .dcl-ordered-checklist-support-rail-root p, .dcl-ordered-checklist-support-rail-root ul, .dcl-ordered-checklist-support-rail-root ol, .dcl-ordered-checklist-support-rail-root dl, .dcl-ordered-checklist-support-rail-root dd, .dcl-ordered-checklist-support-rail-root figure, .dcl-ordered-checklist-support-rail-root blockquote, .dcl-ordered-checklist-support-rail-root fieldset { margin: 0; }
.dcl-ordered-checklist-support-rail-root h2 { font-size: clamp(1.375rem, 3vw, 2rem); line-height: 1.18; }
.dcl-ordered-checklist-support-rail-root h3 { font-size: 1.125rem; line-height: 1.3; }
.dcl-ordered-checklist-support-rail-root ul, .dcl-ordered-checklist-support-rail-root ol { padding: 0; list-style: none; }
.dcl-ordered-checklist-support-rail-panel > * + *, .dcl-ordered-checklist-support-rail-disclosure > * + * { margin-block-start: 0.65rem; }
.dcl-ordered-checklist-support-rail-stack, .dcl-ordered-checklist-support-rail-grid, .dcl-ordered-checklist-support-rail-split, .dcl-ordered-checklist-support-rail-rail { display: grid; gap: 1rem; align-items: start; }
.dcl-ordered-checklist-support-rail-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.dcl-ordered-checklist-support-rail-split { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.dcl-ordered-checklist-support-rail-rail { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.dcl-ordered-checklist-support-rail-bar { display: flex; flex-wrap: wrap; gap: 0.625rem; align-items: center; }
.dcl-ordered-checklist-support-rail-spread { justify-content: space-between; }
.dcl-ordered-checklist-support-rail-panel { padding: 1rem; border: 1px solid var(--edge); border-radius: 0.625rem; }
.dcl-ordered-checklist-support-rail-badge { display: inline-block; width: fit-content; border: 1px solid var(--edge); border-radius: 1rem;
  padding: 0.16rem 0.65rem; font-size: 0.875rem; font-weight: 650; }
.dcl-ordered-checklist-support-rail-muted { font-size: 0.875rem; }
.dcl-ordered-checklist-support-rail-root button, .dcl-ordered-checklist-support-rail-root input, .dcl-ordered-checklist-support-rail-root select, .dcl-ordered-checklist-support-rail-root summary {
  font: inherit; padding: 0.45rem 0.7rem; border: 1px solid; border-radius: 0.375rem; max-inline-size: 100%; }
.dcl-ordered-checklist-support-rail-root input[type="checkbox"], .dcl-ordered-checklist-support-rail-root input[type="radio"] { inline-size: 1.15rem; block-size: 1.15rem; accent-color: var(--accent); }
.dcl-ordered-checklist-support-rail-root button, .dcl-ordered-checklist-support-rail-root select, .dcl-ordered-checklist-support-rail-root summary, .dcl-ordered-checklist-support-rail-root label { cursor: pointer; }
.dcl-ordered-checklist-support-rail-root button:disabled { cursor: not-allowed; border-style: dashed; }
.dcl-ordered-checklist-support-rail-root button:active, .dcl-ordered-checklist-support-rail-root summary:active { text-decoration: underline; }
.dcl-ordered-checklist-support-rail-root a { display: inline-block; padding: 0.2rem; text-underline-offset: 0.2em; }
.dcl-ordered-checklist-support-rail-root a:hover { text-decoration-thickness: 2px; }
.dcl-ordered-checklist-support-rail-root fieldset { padding: 0.75rem; border: 1px solid var(--edge); border-radius: 0.5rem; }
.dcl-ordered-checklist-support-rail-root legend { font-weight: 700; padding-inline: 0.35rem; }
.dcl-ordered-checklist-support-rail-scroll { overflow-x: auto; padding: 0.2rem; }
.dcl-ordered-checklist-support-rail-root table { border-collapse: collapse; inline-size: 100%; text-align: start; }
.dcl-ordered-checklist-support-rail-root caption { text-align: start; font-weight: 700; padding-block: 0.375rem; }
.dcl-ordered-checklist-support-rail-root td, .dcl-ordered-checklist-support-rail-root th { border-block-end: 1px solid var(--edge); padding: 0.5rem; text-align: start; }
.dcl-ordered-checklist-support-rail-root svg { display: block; max-inline-size: 100%; block-size: auto; }
.dcl-ordered-checklist-support-rail-border { border-inline-start: 0.25rem solid var(--accent); padding-inline-start: 0.875rem; }
.dcl-ordered-checklist-support-rail-center { text-align: center; justify-items: center; }
.dcl-ordered-checklist-support-rail-center svg { margin-inline: auto; }
.dcl-ordered-checklist-support-rail-root [hidden] { display: none; }
.dcl-ordered-checklist-support-rail-stack[hidden], .dcl-ordered-checklist-support-rail-bar[hidden] { display: none; }
@media (max-width: 34rem) { .dcl-ordered-checklist-support-rail-rail { grid-template-columns: minmax(0, 1fr); } }

</style>

When to use

Use when people need a standing list of materials or prerequisites beside ordered tasks.

Avoid

Do not place additional required steps in an unnumbered reference rail.

Accessibility

Native checkboxes are labelled in step order. A polite status reports progress without moving focus. Theme token text pairs reach at least 6.2:1 in light and 6.8:1 in dark.

Was this useful? Send feedback.