Component Library

← Back to gallery

Profile identity skeleton in HTML, CSS and vanilla JS

A copy-paste Profile identity skeleton in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.

Category: Feedback · Tags: loading, skeleton, placeholder, preview

Live preview

Source (copy-ready)

<section class="dcl-skeleton-profile-identity" data-dcl-scheme="light" aria-label="Profile identity skeleton example">
<div data-stack>
  <div data-row data-spread><h2>Member card</h2><button type="button" data-toggle>Show loaded example</button></div>
  <p role="status">Member card loading.</p>
  <div data-stack data-placeholder aria-hidden="true"><div data-row><span data-shape data-avatar></span><div data-stack data-grow><span data-shape></span><span data-shape></span></div></div></div>
  <div data-stack data-loaded hidden><article data-row data-well><span data-chip aria-hidden="true">JL</span><div><h3>Jules Lane</h3><p>Receiving coordinator</p></div></article></div>
</div>
<script>
(() => {
  const root = document.currentScript.closest(".dcl-skeleton-profile-identity");
  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);
  const toggle = find("[data-toggle]");
  const loaded = find("[data-loaded]");
  const placeholder = find("[data-placeholder]");
  toggle.addEventListener("click", () => {
    loaded.hidden = !loaded.hidden;
    placeholder.hidden = !loaded.hidden;
    toggle.textContent = loaded.hidden ? "Show loaded example" : "Show loading example";
    find('[role="status"]').textContent = loaded.hidden ? "Loading example." : "Example loaded.";
  });
})();
</script>
</section>
<style>
.dcl-skeleton-profile-identity, .dcl-skeleton-profile-identity * { box-sizing: border-box; }
.dcl-skeleton-profile-identity { 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-skeleton-profile-identity :where(h2, h3, p, ol, ul, dl, dd) { margin: 0; }
.dcl-skeleton-profile-identity h2 { font-size: 1.25rem; line-height: 1.25; }
.dcl-skeleton-profile-identity h3 { font-size: 1rem; }
.dcl-skeleton-profile-identity p + p { margin-block-start: 0.5rem; }
.dcl-skeleton-profile-identity [data-stack], .dcl-skeleton-profile-identity form { display: grid; gap: 0.75rem; }
.dcl-skeleton-profile-identity [data-row] { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; }
.dcl-skeleton-profile-identity [data-split] { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0.75rem 1.25rem; align-items: start; }
.dcl-skeleton-profile-identity [data-spread] { justify-content: space-between; }
.dcl-skeleton-profile-identity [hidden] { display: none !important; }
.dcl-skeleton-profile-identity [data-well] { padding: 0.75rem; border-radius: 0.375rem; }
.dcl-skeleton-profile-identity [data-chip] { display: inline-block; width: fit-content; padding: 0.125rem 0.55rem; border-radius: 99rem; font-size: 0.875rem; font-weight: 700; }
.dcl-skeleton-profile-identity :where(button, summary, input, select) { font: inherit; }
.dcl-skeleton-profile-identity :where(button, input, select) { min-block-size: 44px; min-inline-size: 0; max-inline-size: 100%; }
.dcl-skeleton-profile-identity :where(button, input, select) { border: 1px solid; border-radius: 0.375rem; padding: 0.45rem 0.7rem; }
.dcl-skeleton-profile-identity :where(button, summary) { cursor: pointer; font-weight: 650; }
.dcl-skeleton-profile-identity :where(button, summary):active { box-shadow: inset 0 0 0 2px currentColor; }
.dcl-skeleton-profile-identity summary:hover { text-decoration: underline; }
.dcl-skeleton-profile-identity :where(button, input, select):disabled, .dcl-skeleton-profile-identity [aria-disabled=true] { cursor: not-allowed; border-style: dashed; }
.dcl-skeleton-profile-identity label { display: grid; gap: 0.25rem; }
.dcl-skeleton-profile-identity :where(input, select) { inline-size: 100%; }
.dcl-skeleton-profile-identity label[data-choice] { display: flex; gap: 0.5rem; align-items: center; min-block-size: 44px; }
.dcl-skeleton-profile-identity label[data-choice] input { inline-size: 1.25rem; block-size: 1.25rem; min-block-size: 0; flex-shrink: 0; }
.dcl-skeleton-profile-identity fieldset { min-inline-size: 0; margin: 0; border-radius: 0.375rem; padding: 0.5rem 0.75rem; }
.dcl-skeleton-profile-identity :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }
.dcl-skeleton-profile-identity [data-shape] { display: block; min-block-size: 0.8rem; border: 1px solid #697f84; border-radius: 0.375rem; background-color: #e4edef; }
.dcl-skeleton-profile-identity[data-dcl-scheme=dark] [data-shape] { border-color: #839fa5; background-color: #1c3c44; }
.dcl-skeleton-profile-identity [data-avatar] { inline-size: 3rem; block-size: 3rem; border-radius: 50%; }
.dcl-skeleton-profile-identity [data-grow] { flex: 1 1 11rem; }
.dcl-skeleton-profile-identity [data-grow] span:last-child { inline-size: 58%; }
.dcl-skeleton-profile-identity { color-scheme: light; border-color: #697f84; }
.dcl-skeleton-profile-identity { color: #11292f; background-color: #ffffff; }
.dcl-skeleton-profile-identity [data-well], .dcl-skeleton-profile-identity [data-chip] { color: #11292f; background-color: #e4edef; }
.dcl-skeleton-profile-identity button, .dcl-skeleton-profile-identity input, .dcl-skeleton-profile-identity select { color: #11292f; background-color: #e4edef; }
.dcl-skeleton-profile-identity button[data-primary] { color: #ffffff; background-color: #00535a; }
.dcl-skeleton-profile-identity button:hover { color: #ffffff; background-color: #003c42; }
.dcl-skeleton-profile-identity button[disabled], .dcl-skeleton-profile-identity button[aria-disabled=true] { color: #405a60; background-color: #e4edef; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] { color-scheme: dark; border-color: #839fa5; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] [data-well], .dcl-skeleton-profile-identity[data-dcl-scheme="dark"] [data-chip] { color: #eff8f9; background-color: #1c3c44; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] button, .dcl-skeleton-profile-identity[data-dcl-scheme="dark"] input, .dcl-skeleton-profile-identity[data-dcl-scheme="dark"] select { color: #eff8f9; background-color: #1c3c44; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] button[data-primary] { color: #11292f; background-color: #8fe1da; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] button:hover { color: #11292f; background-color: #b2f2ec; }
.dcl-skeleton-profile-identity[data-dcl-scheme="dark"] button[disabled], .dcl-skeleton-profile-identity[data-dcl-scheme="dark"] button[aria-disabled=true] { color: #b0c9ce; background-color: #1c3c44; }
</style>

When to use

Reserve the avatar, title, and description layout in one compact horizontal panel.

Avoid

Do not announce each placeholder shape as separate content.

Accessibility

Only the overall loading state is announced. The silhouette is decorative and static. Text contrast is at least 6.1:1 in light and 6.7:1 in dark.

Was this useful? Send feedback.