Home / Learn / How do you build a skeleton loading screen instead of a spinner?

How do you build a skeleton loading screen instead of a spinner?

Instead of making the user stare at a blank screen, show a gray shape that hints at the coming content. Here you will learn the moving shimmer effect you see in the biggest apps.

Steps

  1. Draw gray blocks with the same dimensions as the real content: a circle for the avatar, lines for text.
  2. Give each block a gradient background from gray to lighter gray and back, sized at 200%.
  3. Animate the background position in a looping keyframes so the shine sweeps across the blocks.
  4. Add aria-busy="true" to the container so assistive tech knows content is loading.
  5. Disable the animation under prefers-reduced-motion and keep the static gray blocks.

The code

HTML

<div class="skeleton-card" aria-busy="true" aria-label="جارٍ تحميل المحتوى">
  <div class="sk sk-avatar"></div>
  <div class="sk sk-line sk-w60"></div>
  <div class="sk sk-line"></div>
  <div class="sk sk-line sk-w80"></div>
</div>

<style>
.skeleton-card {
  width: 280px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: grid;
  gap: 12px;
}
.sk {
  border-radius: 8px;
  background: linear-gradient(90deg, #ececec 25%, #f7f7f7 50%, #ececec 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s linear infinite;
}
.sk-avatar { width: 48px; height: 48px; border-radius: 50%; }
.sk-line { height: 14px; }
.sk-w60 { width: 60%; }
.sk-w80 { width: 80%; }
@keyframes sk-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}
</style>

RTL & Arabic notes: the shimmer sweeps horizontally and works in both directions unchanged; the blocks hold no text, so letter joining is not a concern.

Didn't find the motion you need? Request it from the Vellox team.