Restricted library empty state in HTML, CSS and vanilla JS
A copy-paste Restricted library empty state in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="dcl-empty-private-library" data-dcl-scheme="light" aria-label="Restricted library empty state example">
<div data-stack>
<div><span data-chip>Restricted view</span><h2>No shared files to show</h2></div>
<p>Only owners can see files in this collection until they share it.</p>
<div data-well data-row data-spread><p>Workspace owners review access requests.</p><button type="button">Preview access request</button></div>
<p role="status"></p>
</div>
<script>
(() => {
const root = document.currentScript.closest(".dcl-empty-private-library");
const preference = matchMedia("(prefers-color-scheme: dark)");
const setTheme = () => { root.dataset.dclScheme = preference.matches ? "dark" : "light"; };
preference.addEventListener("change", setTheme);
setTheme();
const find = (selector) => root.querySelector(selector);
find("button").addEventListener("click", () => {
find('[role="status"]').textContent = "An access request would go to a workspace owner. Nothing was sent.";
});
})();
</script>
</section>
<style>
.dcl-empty-private-library, .dcl-empty-private-library * { box-sizing: border-box; }
.dcl-empty-private-library { 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-empty-private-library :where(h2, h3, p, ol, ul, dl, dd) { margin: 0; }
.dcl-empty-private-library h2 { font-size: 1.25rem; line-height: 1.25; }
.dcl-empty-private-library h3 { font-size: 1rem; }
.dcl-empty-private-library p + p { margin-block-start: 0.5rem; }
.dcl-empty-private-library [data-stack], .dcl-empty-private-library form { display: grid; gap: 0.75rem; }
.dcl-empty-private-library [data-row] { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; }
.dcl-empty-private-library [data-split] { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0.75rem 1.25rem; align-items: start; }
.dcl-empty-private-library [data-spread] { justify-content: space-between; }
.dcl-empty-private-library [hidden] { display: none !important; }
.dcl-empty-private-library [data-well] { padding: 0.75rem; border-radius: 0.375rem; }
.dcl-empty-private-library [data-chip] { display: inline-block; width: fit-content; padding: 0.125rem 0.55rem; border-radius: 99rem; font-size: 0.875rem; font-weight: 700; }
.dcl-empty-private-library :where(button, summary, input, select) { font: inherit; }
.dcl-empty-private-library :where(button, input, select) { min-block-size: 44px; min-inline-size: 0; max-inline-size: 100%; }
.dcl-empty-private-library :where(button, input, select) { border: 1px solid; border-radius: 0.375rem; padding: 0.45rem 0.7rem; }
.dcl-empty-private-library :where(button, summary) { cursor: pointer; font-weight: 650; }
.dcl-empty-private-library :where(button, summary):active { box-shadow: inset 0 0 0 2px currentColor; }
.dcl-empty-private-library summary:hover { text-decoration: underline; }
.dcl-empty-private-library :where(button, input, select):disabled, .dcl-empty-private-library [aria-disabled=true] { cursor: not-allowed; border-style: dashed; }
.dcl-empty-private-library label { display: grid; gap: 0.25rem; }
.dcl-empty-private-library :where(input, select) { inline-size: 100%; }
.dcl-empty-private-library label[data-choice] { display: flex; gap: 0.5rem; align-items: center; min-block-size: 44px; }
.dcl-empty-private-library label[data-choice] input { inline-size: 1.25rem; block-size: 1.25rem; min-block-size: 0; flex-shrink: 0; }
.dcl-empty-private-library fieldset { min-inline-size: 0; margin: 0; border-radius: 0.375rem; padding: 0.5rem 0.75rem; }
.dcl-empty-private-library :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.dcl-empty-private-library[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }
.dcl-empty-private-library { color-scheme: light; border-color: #697f84; }
.dcl-empty-private-library { color: #11292f; background-color: #ffffff; }
.dcl-empty-private-library [data-well], .dcl-empty-private-library [data-chip] { color: #11292f; background-color: #e4edef; }
.dcl-empty-private-library button, .dcl-empty-private-library input, .dcl-empty-private-library select { color: #11292f; background-color: #e4edef; }
.dcl-empty-private-library button[data-primary] { color: #ffffff; background-color: #00535a; }
.dcl-empty-private-library button:hover { color: #ffffff; background-color: #003c42; }
.dcl-empty-private-library button[disabled], .dcl-empty-private-library button[aria-disabled=true] { color: #405a60; background-color: #e4edef; }
.dcl-empty-private-library[data-dcl-scheme="dark"] { color-scheme: dark; border-color: #839fa5; }
.dcl-empty-private-library[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; }
.dcl-empty-private-library[data-dcl-scheme="dark"] [data-well], .dcl-empty-private-library[data-dcl-scheme="dark"] [data-chip] { color: #eff8f9; background-color: #1c3c44; }
.dcl-empty-private-library[data-dcl-scheme="dark"] button, .dcl-empty-private-library[data-dcl-scheme="dark"] input, .dcl-empty-private-library[data-dcl-scheme="dark"] select { color: #eff8f9; background-color: #1c3c44; }
.dcl-empty-private-library[data-dcl-scheme="dark"] button[data-primary] { color: #11292f; background-color: #8fe1da; }
.dcl-empty-private-library[data-dcl-scheme="dark"] button:hover { color: #11292f; background-color: #b2f2ec; }
.dcl-empty-private-library[data-dcl-scheme="dark"] button[disabled], .dcl-empty-private-library[data-dcl-scheme="dark"] button[aria-disabled=true] { color: #b0c9ce; background-color: #1c3c44; }
</style>
When to use
Explain why a collection looks empty to a member who cannot see its contents, and offer the correct next step.
Avoid
Do not expose filenames or other resource metadata to a person without permission.
Accessibility
The reason and access action are adjacent. Activation updates an existing polite status without stealing focus. Text contrast is at least 6.1:1 in light and 6.7:1 in dark.
Was this useful? Send feedback.