Skip to content

Skeleton

For laying out the shape of content about to arrive, so the page doesn't jump when it lands.

Feedback

Live preview

Source

<div class="dc-skel">
  <p class="dc-sr" role="status">내용을 불러오는 중입니다</p>
  <div class="dc-skel__card" aria-hidden="true">
    <div class="dc-skel__shape dc-skel__media"></div>
    <div class="dc-skel__stack">
      <div class="dc-skel__shape dc-skel__line dc-skel__line--title"></div>
      <div class="dc-skel__shape dc-skel__line"></div>
      <div class="dc-skel__shape dc-skel__line dc-skel__line--short"></div>
    </div>
  </div>
</div>
.dc-skel { max-width: 420px; font-family: var(--dc-font); }
.dc-skel__card {
  display: flex; flex-direction: column; gap: var(--dc-3);
  padding: var(--dc-4);
  border: 1px solid var(--dc-line);
  border-radius: var(--dc-r-md);
  background: var(--dc-surface);
}
.dc-skel__stack { display: flex; flex-direction: column; gap: var(--dc-2); flex: 1 1 auto; min-width: 0; }
.dc-skel__shape {
  position: relative; overflow: hidden;
  background: var(--dc-sunken);
  border-radius: var(--dc-r-xs);
}
.dc-skel__shape::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--dc-text) 9%, transparent), transparent);
  animation: dc-skel-pass 1400ms ease-in-out infinite;
}
.dc-skel__media { height: 140px; border-radius: var(--dc-r-sm); }
.dc-skel__line { height: 12px; }
.dc-skel__line--title { height: 16px; width: 62%; }
.dc-skel__line--short { width: 40%; }
.dc-skel__avatar { flex: none; width: 44px; height: 44px; border-radius: var(--dc-r-full); }
.dc-skel__list { display: flex; flex-direction: column; gap: var(--dc-4); margin: 0; padding: 0; list-style: none; }
.dc-skel__row { display: flex; align-items: center; gap: var(--dc-3); }
@keyframes dc-skel-pass { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .dc-skel__shape::after { display: none; }
}

How to use it

  • Match the real height and the real number of rows — a mismatch makes the page jump
  • Use it for a first load; reloading a list people already saw, keep the old content and show a spinner
  • It fills a whole block, not one or two small fields

Watch out for

  • Hide the shapes with aria-hidden and leave one spoken line beside them
  • Don't shimmer forever — when the load fails, swap in an error state

Next