Expandable notification inbox in HTML, CSS and vanilla JS
A copy-paste Expandable notification inbox in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="dcl-notifications-expandable-inbox" data-dcl-scheme="light" aria-label="Expandable notification inbox example">
<div data-stack>
<h2>Project inbox</h2>
<details data-well><summary>Review due Tuesday: label proofs</summary><p>Approve the size and spacing on the side panel before Tuesday at noon.</p></details>
<details data-well><summary>Delivery date changed</summary><p>The pallet is now expected on Thursday morning. No action is required.</p></details>
<details data-well><summary>New teammate joined</summary><p>Jamie joined the proofing group as a reviewer.</p></details>
</div>
<script>
(() => {
const root = document.currentScript.closest(".dcl-notifications-expandable-inbox");
const preference = matchMedia("(prefers-color-scheme: dark)");
const setTheme = () => { root.dataset.dclScheme = preference.matches ? "dark" : "light"; };
preference.addEventListener("change", setTheme);
setTheme();
})();
</script>
</section>
<style>
.dcl-notifications-expandable-inbox, .dcl-notifications-expandable-inbox * { box-sizing: border-box; }
.dcl-notifications-expandable-inbox { font: 1rem/1.5 system-ui, sans-serif; max-inline-size: 40rem; padding: clamp(0.75rem, 3vw, 1.25rem); border: 1px solid; border-radius: 0.75rem; overflow-wrap: anywhere; }
.dcl-notifications-expandable-inbox :where(h2, h3, p, ol, ul, dl, dd) { margin: 0; }
.dcl-notifications-expandable-inbox h2 { font-size: 1.25rem; line-height: 1.25; }
.dcl-notifications-expandable-inbox h3 { font-size: 1rem; }
.dcl-notifications-expandable-inbox p + p { margin-block-start: 0.5rem; }
.dcl-notifications-expandable-inbox [data-stack], .dcl-notifications-expandable-inbox form { display: grid; gap: 0.75rem; }
.dcl-notifications-expandable-inbox [data-row] { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; }
.dcl-notifications-expandable-inbox [data-split] { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0.75rem 1.25rem; align-items: start; }
.dcl-notifications-expandable-inbox [data-spread] { justify-content: space-between; }
.dcl-notifications-expandable-inbox [hidden] { display: none !important; }
.dcl-notifications-expandable-inbox [data-well] { padding: 0.75rem; border-radius: 0.375rem; }
.dcl-notifications-expandable-inbox [data-chip] { display: inline-block; width: fit-content; padding: 0.125rem 0.55rem; border-radius: 99rem; font-size: 0.875rem; font-weight: 700; }
.dcl-notifications-expandable-inbox :where(button, summary, input, select) { font: inherit; }
.dcl-notifications-expandable-inbox :where(button, input, select) { min-block-size: 44px; min-inline-size: 0; max-inline-size: 100%; }
.dcl-notifications-expandable-inbox :where(button, input, select) { border: 1px solid; border-radius: 0.375rem; padding: 0.45rem 0.7rem; }
.dcl-notifications-expandable-inbox :where(button, summary) { cursor: pointer; font-weight: 650; }
.dcl-notifications-expandable-inbox :where(button, summary):active { box-shadow: inset 0 0 0 2px currentColor; }
.dcl-notifications-expandable-inbox summary:hover { text-decoration: underline; }
.dcl-notifications-expandable-inbox :where(button, input, select):disabled, .dcl-notifications-expandable-inbox [aria-disabled=true] { cursor: not-allowed; border-style: dashed; }
.dcl-notifications-expandable-inbox label { display: grid; gap: 0.25rem; }
.dcl-notifications-expandable-inbox :where(input, select) { inline-size: 100%; }
.dcl-notifications-expandable-inbox label[data-choice] { display: flex; gap: 0.5rem; align-items: center; min-block-size: 44px; }
.dcl-notifications-expandable-inbox label[data-choice] input { inline-size: 1.25rem; block-size: 1.25rem; min-block-size: 0; flex-shrink: 0; }
.dcl-notifications-expandable-inbox fieldset { min-inline-size: 0; margin: 0; border-radius: 0.375rem; padding: 0.5rem 0.75rem; }
.dcl-notifications-expandable-inbox :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }
.dcl-notifications-expandable-inbox { color-scheme: light; border-color: #697f84; }
.dcl-notifications-expandable-inbox { color: #11292f; background-color: #ffffff; }
.dcl-notifications-expandable-inbox [data-well], .dcl-notifications-expandable-inbox [data-chip] { color: #11292f; background-color: #e4edef; }
.dcl-notifications-expandable-inbox button, .dcl-notifications-expandable-inbox input, .dcl-notifications-expandable-inbox select { color: #11292f; background-color: #e4edef; }
.dcl-notifications-expandable-inbox button[data-primary] { color: #ffffff; background-color: #00535a; }
.dcl-notifications-expandable-inbox button:hover { color: #ffffff; background-color: #003c42; }
.dcl-notifications-expandable-inbox button[disabled], .dcl-notifications-expandable-inbox button[aria-disabled=true] { color: #405a60; background-color: #e4edef; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] { color-scheme: dark; border-color: #839fa5; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] [data-well], .dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] [data-chip] { color: #eff8f9; background-color: #1c3c44; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] button, .dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] input, .dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] select { color: #eff8f9; background-color: #1c3c44; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] button[data-primary] { color: #11292f; background-color: #8fe1da; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] button:hover { color: #11292f; background-color: #b2f2ec; }
.dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] button[disabled], .dcl-notifications-expandable-inbox[data-dcl-scheme="dark"] button[aria-disabled=true] { color: #b0c9ce; background-color: #1c3c44; }
</style>
When to use
Expand full message details without taking readers away from a compact inbox.
Avoid
Put deadlines on the row itself rather than making readers open each item to find them.
Accessibility
Every native disclosure has its own concise subject and operates with Enter or Space. Text contrast is at least 6.1:1 in light and 6.7:1 in dark.
Was this useful? Send feedback.