CSSmediumCSS

Skeleton Loading Animation

Create skeleton screens for content loading states.

01

The problem

You need placeholder content while data is loading to improve perceived performance.

02

The solution

CSS
.skeleton {
  background: linear-gradient(
    90deg,
    #1a1a2e 25%,
    #2a2a4e 50%,
    #1a1a2e 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton elements */
.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-title {
  height: 24px;
  width: 80%;
  margin-bottom: 16px;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-image {
  width: 100%;
  height: 200px;
  border-radius: 8px;
}

03

See it live

Isolated previewSandboxed
04

Put it to work

Example
<!-- Skeleton card while loading -->
<div class="card skeleton-card">
  <div class="skeleton skeleton-image"></div>
  <div class="skeleton skeleton-title"></div>
  <div class="skeleton skeleton-text"></div>
  <div class="skeleton skeleton-text short"></div>
</div>

Worth knowing

Skeleton screens feel faster than spinners. Match skeleton shapes to your actual content layout.