Checklist with an unfinished filter in HTML, CSS and vanilla JS
A copy-paste Checklist with an unfinished filter in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="dcl-ordered-checklist-completion-filter-root" aria-label="Ordered checklist with unfinished-step filter" data-dcl-scheme="light">
<h2>Track the archive handoff</h2><progress max="3" value="0" aria-label="Handoff progress"></progress><p role="status">0 of 3 steps complete</p><button type="button" aria-pressed="false">Show unfinished only</button><ol class="dcl-ordered-checklist-completion-filter-stack" role="list"><li><div class="dcl-ordered-checklist-completion-filter-panel"><label class="dcl-ordered-checklist-completion-filter-bar"><input type="checkbox" value="0" > 1. Check identifiers</label><p class="dcl-ordered-checklist-completion-filter-muted">Confirm that each box has a unique label.</p></div></li>
<li><div class="dcl-ordered-checklist-completion-filter-panel"><label class="dcl-ordered-checklist-completion-filter-bar"><input type="checkbox" value="1" > 2. Make a working copy</label><p class="dcl-ordered-checklist-completion-filter-muted">Keep the original scans unchanged.</p></div></li>
<li><div class="dcl-ordered-checklist-completion-filter-panel"><label class="dcl-ordered-checklist-completion-filter-bar"><input type="checkbox" value="2" > 3. Record the handoff</label><p class="dcl-ordered-checklist-completion-filter-muted">Name the recipient and location.</p></div></li></ol>
<script>
(() => {
const root = document.currentScript.closest(".dcl-ordered-checklist-completion-filter-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);
const filter = root.querySelector("button");
function refresh() {
const enabled = filter.getAttribute("aria-pressed") === "true";
const active = document.activeElement;
fields.forEach((field) => { field.closest("li").hidden = enabled && field.checked; });
if (fields.includes(active) && active.closest("li").hidden) {
(fields.find((field) => !field.closest("li").hidden) || filter).focus();
}
}
filter.addEventListener("click", () => {
filter.setAttribute("aria-pressed", String(filter.getAttribute("aria-pressed") !== "true"));
refresh();
});
root.addEventListener("change", refresh);
})();
</script>
</section>
<style>
.dcl-ordered-checklist-completion-filter-root { color: #11292f; background-color: #ffffff; color-scheme: light; }
.dcl-ordered-checklist-completion-filter-root .dcl-ordered-checklist-completion-filter-panel, .dcl-ordered-checklist-completion-filter-root .dcl-ordered-checklist-completion-filter-badge,
.dcl-ordered-checklist-completion-filter-root button, .dcl-ordered-checklist-completion-filter-root input, .dcl-ordered-checklist-completion-filter-root select, .dcl-ordered-checklist-completion-filter-root summary {
color: #11292f; background-color: #e4edef; border-color: #697f84;
}
.dcl-ordered-checklist-completion-filter-root .dcl-ordered-checklist-completion-filter-muted { color: #405a60; }
.dcl-ordered-checklist-completion-filter-root button:hover, .dcl-ordered-checklist-completion-filter-root button[aria-pressed="true"], .dcl-ordered-checklist-completion-filter-root summary:hover {
color: #ffffff; background-color: #00535a;
}
.dcl-ordered-checklist-completion-filter-root a { color: #005c62; }
.dcl-ordered-checklist-completion-filter-root :focus-visible { outline: 3px solid #005c62; outline-offset: 3px; }
.dcl-ordered-checklist-completion-filter-root { --edge: #697f84; --accent: #00535a; }
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; color-scheme: dark; }
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] .dcl-ordered-checklist-completion-filter-panel, .dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] .dcl-ordered-checklist-completion-filter-badge,
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] button, .dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] input, .dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] select, .dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] summary {
color: #eff8f9; background-color: #1c3c44; border-color: #839fa5;
}
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] .dcl-ordered-checklist-completion-filter-muted { color: #b0c9ce; }
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] button:hover, .dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] button[aria-pressed="true"], .dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] summary:hover {
color: #11292f; background-color: #8fe1da;
}
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] a { color: #8fe1da; }
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 3px; }
.dcl-ordered-checklist-completion-filter-root[data-dcl-scheme="dark"] { --edge: #839fa5; --accent: #8fe1da; }
.dcl-ordered-checklist-completion-filter-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-completion-filter-root * { box-sizing: border-box; min-inline-size: 0; }
.dcl-ordered-checklist-completion-filter-root h2, .dcl-ordered-checklist-completion-filter-root h3, .dcl-ordered-checklist-completion-filter-root p, .dcl-ordered-checklist-completion-filter-root ul, .dcl-ordered-checklist-completion-filter-root ol, .dcl-ordered-checklist-completion-filter-root dl, .dcl-ordered-checklist-completion-filter-root dd, .dcl-ordered-checklist-completion-filter-root figure, .dcl-ordered-checklist-completion-filter-root blockquote, .dcl-ordered-checklist-completion-filter-root fieldset { margin: 0; }
.dcl-ordered-checklist-completion-filter-root h2 { font-size: clamp(1.375rem, 3vw, 2rem); line-height: 1.18; }
.dcl-ordered-checklist-completion-filter-root h3 { font-size: 1.125rem; line-height: 1.3; }
.dcl-ordered-checklist-completion-filter-root ul, .dcl-ordered-checklist-completion-filter-root ol { padding: 0; list-style: none; }
.dcl-ordered-checklist-completion-filter-panel > * + *, .dcl-ordered-checklist-completion-filter-disclosure > * + * { margin-block-start: 0.65rem; }
.dcl-ordered-checklist-completion-filter-stack, .dcl-ordered-checklist-completion-filter-grid, .dcl-ordered-checklist-completion-filter-split, .dcl-ordered-checklist-completion-filter-rail { display: grid; gap: 1rem; align-items: start; }
.dcl-ordered-checklist-completion-filter-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.dcl-ordered-checklist-completion-filter-split { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.dcl-ordered-checklist-completion-filter-rail { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.dcl-ordered-checklist-completion-filter-bar { display: flex; flex-wrap: wrap; gap: 0.625rem; align-items: center; }
.dcl-ordered-checklist-completion-filter-spread { justify-content: space-between; }
.dcl-ordered-checklist-completion-filter-panel { padding: 1rem; border: 1px solid var(--edge); border-radius: 0.625rem; }
.dcl-ordered-checklist-completion-filter-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-completion-filter-muted { font-size: 0.875rem; }
.dcl-ordered-checklist-completion-filter-root button, .dcl-ordered-checklist-completion-filter-root input, .dcl-ordered-checklist-completion-filter-root select, .dcl-ordered-checklist-completion-filter-root summary {
font: inherit; padding: 0.45rem 0.7rem; border: 1px solid; border-radius: 0.375rem; max-inline-size: 100%; }
.dcl-ordered-checklist-completion-filter-root input[type="checkbox"], .dcl-ordered-checklist-completion-filter-root input[type="radio"] { inline-size: 1.15rem; block-size: 1.15rem; accent-color: var(--accent); }
.dcl-ordered-checklist-completion-filter-root button, .dcl-ordered-checklist-completion-filter-root select, .dcl-ordered-checklist-completion-filter-root summary, .dcl-ordered-checklist-completion-filter-root label { cursor: pointer; }
.dcl-ordered-checklist-completion-filter-root button:disabled { cursor: not-allowed; border-style: dashed; }
.dcl-ordered-checklist-completion-filter-root button:active, .dcl-ordered-checklist-completion-filter-root summary:active { text-decoration: underline; }
.dcl-ordered-checklist-completion-filter-root a { display: inline-block; padding: 0.2rem; text-underline-offset: 0.2em; }
.dcl-ordered-checklist-completion-filter-root a:hover { text-decoration-thickness: 2px; }
.dcl-ordered-checklist-completion-filter-root fieldset { padding: 0.75rem; border: 1px solid var(--edge); border-radius: 0.5rem; }
.dcl-ordered-checklist-completion-filter-root legend { font-weight: 700; padding-inline: 0.35rem; }
.dcl-ordered-checklist-completion-filter-scroll { overflow-x: auto; padding: 0.2rem; }
.dcl-ordered-checklist-completion-filter-root table { border-collapse: collapse; inline-size: 100%; text-align: start; }
.dcl-ordered-checklist-completion-filter-root caption { text-align: start; font-weight: 700; padding-block: 0.375rem; }
.dcl-ordered-checklist-completion-filter-root td, .dcl-ordered-checklist-completion-filter-root th { border-block-end: 1px solid var(--edge); padding: 0.5rem; text-align: start; }
.dcl-ordered-checklist-completion-filter-root svg { display: block; max-inline-size: 100%; block-size: auto; }
.dcl-ordered-checklist-completion-filter-border { border-inline-start: 0.25rem solid var(--accent); padding-inline-start: 0.875rem; }
.dcl-ordered-checklist-completion-filter-center { text-align: center; justify-items: center; }
.dcl-ordered-checklist-completion-filter-center svg { margin-inline: auto; }
.dcl-ordered-checklist-completion-filter-root [hidden] { display: none; }
.dcl-ordered-checklist-completion-filter-stack[hidden], .dcl-ordered-checklist-completion-filter-bar[hidden] { display: none; }
@media (max-width: 34rem) { .dcl-ordered-checklist-completion-filter-rail { grid-template-columns: minmax(0, 1fr); } }
</style>
When to use
Use when people return to a long checklist and want a view of what remains. Allow them to restore the complete list immediately.
Avoid
Do not make the filter permanent when users may need to correct a checked item.
Accessibility
Native checkboxes are labelled in step order. A polite status reports progress without moving focus. A named progress bar expresses completion. When a focused step is hidden, focus moves to the first unfinished step in list order, or to the filter if none remain. Theme token text pairs reach at least 6.2:1 in light and 6.8:1 in dark.
Was this useful? Send feedback.