Component Library

← Back to gallery

Expandable row data table in HTML, CSS and vanilla JS

A copy-paste Expandable row data table in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.

Category: Tables & lists · Tags: table, expandable-rows, details, deployment

Live preview

Source (copy-ready)

<section class="dcl-expandable-row-table" data-dcl-scheme="light" aria-labelledby="dcl-expandable-row-table-title"><header class="dcl-expandable-row-table__header"><h2 id="dcl-expandable-row-table-title">Expandable row data table</h2><p class="dcl-expandable-row-table__muted">Evidence disclosures live inside table cells while the grid remains semantic.</p></header><table><caption>Deployment detail</caption><thead><tr><th scope="col">Release</th><th scope="col">State</th><th scope="col">Detail</th></tr></thead><tbody><tr><th scope="row">web-42</th><td>Ready</td><td><details><summary>Evidence</summary><p>Render and migration checks passed.</p></details></td></tr><tr><th scope="row">api-18</th><td>Blocked</td><td><details><summary>Evidence</summary><p>Rate-limit documentation is incomplete.</p></details></td></tr></tbody></table><script>(()=>{const root=document.currentScript.closest(".dcl-expandable-row-table");if(!root||root.dataset.dclBound)return;root.dataset.dclBound="1";const instance=Array.from(document.getElementsByClassName("dcl-expandable-row-table")).indexOf(root);if(instance>0){for(const el of [root,...root.querySelectorAll("*")]){for(const attr of ["id","aria-labelledby","aria-controls","aria-describedby","for","name"]){if(el.hasAttribute(attr))el.setAttribute(attr,el.getAttribute(attr)+"--"+instance)}const href=el.getAttribute("href");if(href&&href.startsWith("#"))el.setAttribute("href",href+"--"+instance)}}const preference=matchMedia("(prefers-color-scheme: dark)"),apply=()=>{root.dataset.dclScheme=preference.matches?"dark":"light"};preference.addEventListener("change",apply);apply();const q=(s)=>root.querySelector(s),qa=(s)=>Array.from(root.querySelectorAll(s));})();</script></section>
<style>
.dcl-expandable-row-table{color:#11292f;background-color:#ffffff;color-scheme:light;font:1rem/1.45 system-ui,sans-serif;padding:.8rem;border:1px solid #697f84;border-radius:.6rem;overflow-wrap:anywhere}
.dcl-expandable-row-table *{box-sizing:border-box}.dcl-expandable-row-table h2,.dcl-expandable-row-table h3{line-height:1.15;margin-block:0 .6rem}.dcl-expandable-row-table a{color:#005c62}
.dcl-expandable-row-table button,.dcl-expandable-row-table input,.dcl-expandable-row-table select,.dcl-expandable-row-table textarea,.dcl-expandable-row-table summary{min-block-size:44px;border:1px solid #697f84;border-radius:.3rem;padding:.4rem .65rem;font:inherit;color:#11292f;background-color:#e4edef}
.dcl-expandable-row-table input,.dcl-expandable-row-table select,.dcl-expandable-row-table textarea{background-color:#ffffff}.dcl-expandable-row-table input[type="radio"],.dcl-expandable-row-table input[type="checkbox"]{min-block-size:auto;inline-size:auto}
.dcl-expandable-row-table button,.dcl-expandable-row-table summary{cursor:pointer}.dcl-expandable-row-table button:hover,.dcl-expandable-row-table summary:hover{color:#ffffff;background-color:#00535a}
.dcl-expandable-row-table button:focus-visible,.dcl-expandable-row-table input:focus-visible,.dcl-expandable-row-table select:focus-visible,.dcl-expandable-row-table textarea:focus-visible,.dcl-expandable-row-table summary:focus-visible,.dcl-expandable-row-table a:focus-visible{outline:3px solid #005c62;outline-offset:2px}
.dcl-expandable-row-table details{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.4rem;margin-block-start:.6rem}.dcl-expandable-row-table summary{font-weight:650}
.dcl-expandable-row-table dialog{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.6rem;max-inline-size:min(34rem,92vw);padding:1rem}
.dcl-expandable-row-table table{border-collapse:collapse;inline-size:100%;color:#11292f;background-color:#ffffff}.dcl-expandable-row-table th,.dcl-expandable-row-table td{padding:.4rem;text-align:start;border-block-end:1px solid #697f84}.dcl-expandable-row-table th{color:#11292f;background-color:#e4edef}
.dcl-expandable-row-table [hidden]{display:none!important}.dcl-expandable-row-table__muted{color:#405a60}.dcl-expandable-row-table__panel{color:#405a60;background-color:#ffffff}.dcl-expandable-row-table__well{color:#11292f;background-color:#e4edef}.dcl-expandable-row-table__primary,.dcl-expandable-row-table__badge{color:#ffffff;background-color:#00535a}.dcl-expandable-row-table__badge{border-radius:999px;padding:.1rem .45rem;font-size:.8rem;font-weight:700}
.dcl-expandable-row-table[data-dcl-scheme="dark"]{color:#eff8f9;background-color:#142f36;color-scheme:dark;border-color:#839fa5}.dcl-expandable-row-table[data-dcl-scheme="dark"] a{color:#8fe1da}
.dcl-expandable-row-table[data-dcl-scheme="dark"] button,.dcl-expandable-row-table[data-dcl-scheme="dark"] input,.dcl-expandable-row-table[data-dcl-scheme="dark"] select,.dcl-expandable-row-table[data-dcl-scheme="dark"] textarea,.dcl-expandable-row-table[data-dcl-scheme="dark"] summary{color:#eff8f9;background-color:#1c3c44;border-color:#839fa5}
.dcl-expandable-row-table[data-dcl-scheme="dark"] input,.dcl-expandable-row-table[data-dcl-scheme="dark"] select,.dcl-expandable-row-table[data-dcl-scheme="dark"] textarea{background-color:#142f36}.dcl-expandable-row-table[data-dcl-scheme="dark"] button:hover,.dcl-expandable-row-table[data-dcl-scheme="dark"] summary:hover{color:#11292f;background-color:#8fe1da}
.dcl-expandable-row-table[data-dcl-scheme="dark"] button:focus-visible,.dcl-expandable-row-table[data-dcl-scheme="dark"] input:focus-visible,.dcl-expandable-row-table[data-dcl-scheme="dark"] select:focus-visible,.dcl-expandable-row-table[data-dcl-scheme="dark"] textarea:focus-visible,.dcl-expandable-row-table[data-dcl-scheme="dark"] summary:focus-visible,.dcl-expandable-row-table[data-dcl-scheme="dark"] a:focus-visible{outline-color:#8fe1da}
.dcl-expandable-row-table[data-dcl-scheme="dark"] details,.dcl-expandable-row-table[data-dcl-scheme="dark"] dialog,.dcl-expandable-row-table[data-dcl-scheme="dark"] table{color:#eff8f9;background-color:#142f36;border-color:#839fa5}.dcl-expandable-row-table[data-dcl-scheme="dark"] th{color:#eff8f9;background-color:#1c3c44}.dcl-expandable-row-table[data-dcl-scheme="dark"] th,.dcl-expandable-row-table[data-dcl-scheme="dark"] td{border-color:#839fa5}
.dcl-expandable-row-table[data-dcl-scheme="dark"] .dcl-expandable-row-table__muted{color:#b0c9ce}.dcl-expandable-row-table[data-dcl-scheme="dark"] .dcl-expandable-row-table__panel{color:#b0c9ce;background-color:#142f36}.dcl-expandable-row-table[data-dcl-scheme="dark"] .dcl-expandable-row-table__well{color:#eff8f9;background-color:#1c3c44}.dcl-expandable-row-table[data-dcl-scheme="dark"] .dcl-expandable-row-table__primary,.dcl-expandable-row-table[data-dcl-scheme="dark"] .dcl-expandable-row-table__badge{color:#11292f;background-color:#8fe1da}
@media (prefers-reduced-motion:reduce){.dcl-expandable-row-table *{transition:none!important;animation:none!important}}
.dcl-expandable-row-table details{margin:0;border:0;padding:0}.dcl-expandable-row-table summary{min-block-size:0}</style>

When to use

Use when one optional evidence paragraph supports a scan-first table. Keep detail short so row height changes remain predictable.

Avoid

Do not hide essential state or multiple columns inside row expansion; use a detail page or wider table.

Accessibility

Row detail uses native details inside a table cell without breaking row or column header structure. Status text is written text rather than colour alone and focus is visibly outlined. Light text is #11292f or #405a60 on the surface (15.19:1/7.37:1); dark text is #eff8f9 or #b0c9ce on the dark surface (13.07:1/8.12:1).

Was this useful? Send feedback.