Skip to content

Skeleton ​

Loading placeholders built on Bootstrap placeholders, with a reduced-motion-aware pulse.

Installation ​

bash
npx bootcn add skeleton
bash
pnpm dlx bootcn add skeleton
bash
yarn dlx bootcn add skeleton
bash
bunx --bun bootcn add skeleton

The CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.

Usage ​

html
<div class="bootcn-skeleton-group" aria-busy="true" aria-live="polite">
  <span class="visually-hidden">Loading profile…</span>
  <div aria-hidden="true">
    <span class="placeholder bootcn-skeleton bootcn-skeleton--circle"></span>
    <span class="placeholder bootcn-skeleton bootcn-skeleton--text col-6"></span>
    <span class="placeholder bootcn-skeleton bootcn-skeleton--text col-4"></span>
  </div>
</div>

When the content arrives, replace the group, or remove aria-busy and the placeholders.

Shapes ​

  • bootcn-skeleton--text — a line of text.
  • bootcn-skeleton--circle — an avatar (--bootcn-skeleton-size, default 2.5rem).
  • bootcn-skeleton--block — an image or card area (8rem high; override with style or utilities).

Customizing ​

VariableDefault
--bootcn-skeleton-bgvar(--bs-secondary-bg)
--bootcn-skeleton-duration1.6s

Dependencies ​

  • Bootstrap 5.3+ CSS (.placeholder, .visually-hidden, column classes).
  • themes/tokens/tokens.css.

No JavaScript.

Accessibility ​

  • Mark the loading region with aria-busy="true" and give it a visually hidden text such as "Loading profile…"; hide the placeholder shapes with aria-hidden="true".
  • The pulse animation stops when the user prefers reduced motion.

Source ​

The exact files the CLI installs (skeleton@1.1.0). View on GitHub · Report an issue

html
<div class="bootcn-skeleton-group" aria-busy="true" aria-live="polite">
  <span class="visually-hidden">Loading profile…</span>
  <div class="d-flex align-items-center gap-3" aria-hidden="true">
    <span class="placeholder bootcn-skeleton bootcn-skeleton--circle"></span>
    <div class="flex-grow-1">
      <span class="placeholder bootcn-skeleton bootcn-skeleton--text col-6"></span>
      <span class="placeholder bootcn-skeleton bootcn-skeleton--text col-4"></span>
    </div>
  </div>
  <span class="placeholder bootcn-skeleton bootcn-skeleton--block mt-3" aria-hidden="true"></span>
</div>
css
.bootcn-skeleton {
  --bootcn-skeleton-bg: var(--bootcn-muted);
  --bootcn-skeleton-duration: 1.6s;

  display: block;
  min-height: 1em;
  border-radius: var(--bootcn-radius);
  background-color: var(--bootcn-skeleton-bg);
  opacity: 1;
  cursor: progress;
  animation: bootcn-skeleton-pulse var(--bootcn-skeleton-duration) ease-in-out infinite;
}

.bootcn-skeleton--text {
  height: 0.875rem;
  min-height: 0;
  margin-bottom: 0.5rem;
}

.bootcn-skeleton--text:last-child {
  margin-bottom: 0;
}

.bootcn-skeleton--circle {
  --bootcn-skeleton-size: 2.5rem;

  width: var(--bootcn-skeleton-size);
  height: var(--bootcn-skeleton-size);
  flex-shrink: 0;
  border-radius: 50%;
}

.bootcn-skeleton--block {
  width: 100%;
  height: 8rem;
  border-radius: var(--bootcn-radius);
}

@keyframes bootcn-skeleton-pulse {
  50% {
    opacity: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bootcn-skeleton {
    animation: none;
  }
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.