Component Library

← Back to gallery

Ordered checklist with step details in HTML, CSS and vanilla JS

A copy-paste Ordered checklist with step details 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-step-disclosures-root" aria-label="Ordered checklist with step instructions" data-dcl-scheme="light">
<h2>Check steps as you go</h2><p role="status">0 of 3 steps complete</p><ol class="dcl-ordered-checklist-step-disclosures-stack" role="list"><li><div class="dcl-ordered-checklist-step-disclosures-panel"><label class="dcl-ordered-checklist-step-disclosures-bar"><input type="checkbox" value="0" > 1. Check identifiers</label><details class="dcl-ordered-checklist-step-disclosures-disclosure"><summary>Instructions for step 1</summary><p>Confirm that each box has a unique label.</p></details></div></li>
<li><div class="dcl-ordered-checklist-step-disclosures-panel"><label class="dcl-ordered-checklist-step-disclosures-bar"><input type="checkbox" value="1" > 2. Make a working copy</label><details class="dcl-ordered-checklist-step-disclosures-disclosure"><summary>Instructions for step 2</summary><p>Keep the original scans unchanged.</p></details></div></li>
<li><div class="dcl-ordered-checklist-step-disclosures-panel"><label class="dcl-ordered-checklist-step-disclosures-bar"><input type="checkbox" value="2" > 3. Record the handoff</label><details class="dcl-ordered-checklist-step-disclosures-disclosure"><summary>Instructions for step 3</summary><p>Name the recipient and location.</p></details></div></li></ol>
<script>
(() => {
  const root = document.currentScript.closest(".dcl-ordered-checklist-step-disclosures-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-step-disclosures-root { color: #11292f; background-color: #ffffff; color-scheme: light; }
.dcl-ordered-checklist-step-disclosures-root .dcl-ordered-checklist-step-disclosures-panel, .dcl-ordered-checklist-step-disclosures-root .dcl-ordered-checklist-step-disclosures-badge,
.dcl-ordered-checklist-step-disclosures-root button, .dcl-ordered-checklist-step-disclosures-root input, .dcl-ordered-checklist-step-disclosures-root select, .dcl-ordered-checklist-step-disclosures-root summary {
  color: #11292f; background-color: #e4edef; border-color: #697f84;
}
.dcl-ordered-checklist-step-disclosures-root .dcl-ordered-checklist-step-disclosures-muted { color: #405a60; }
.dcl-ordered-checklist-step-disclosures-root button:hover, .dcl-ordered-checklist-step-disclosures-root button[aria-pressed="true"], .dcl-ordered-checklist-step-disclosures-root summary:hover {
  color: #ffffff; background-color: #00535a;
}
.dcl-ordered-checklist-step-disclosures-root a { color: #005c62; }
.dcl-ordered-checklist-step-disclosures-root :focus-visible { outline: 3px solid #005c62; outline-offset: 3px; }
.dcl-ordered-checklist-step-disclosures-root { --edge: #697f84; --accent: #00535a; }

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

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

</style>

When to use

Use when optional instructions are longer than the step labels and readers should be able to complete a step without expanding them.

Avoid

Do not hide safety or eligibility requirements inside optional instructions.

Accessibility

Native checkboxes are labelled in step order. A polite status reports progress without moving focus. Each step's instruction disclosure is separate from its checkbox. Theme token text pairs reach at least 6.2:1 in light and 6.8:1 in dark.

Was this useful? Send feedback.