Skip to content

Skeleton

Grey shapes that stand in for content while it loads. Same markup and props in every style: switch the style in the header to see it change.

Profile

A round picture and two lines of text.

skeleton-profile.html
<div role="status" aria-label="Loading profile" style="display: flex; align-items: center; gap: 12px; width: 100%; max-width: 280px">
  <div class="vin-skeleton vin-skeleton--circle" style="width: 44px"></div>
  <div style="flex: 1; display: grid; gap: 8px">
    <div class="vin-skeleton vin-skeleton--text" style="width: 70%"></div>
    <div class="vin-skeleton vin-skeleton--text" style="width: 45%"></div>
  </div>
</div>

Card

A media block, a title, text and a button, inside a Card.

skeleton-card.html
<div class="vin-card" role="status" aria-label="Loading article" style="width: 100%; max-width: 300px; overflow: hidden">
  <div class="vin-skeleton" style="height: 140px; border-radius: 0"></div>
  <div class="vin-card__body" style="display: grid; gap: 10px">
    <div class="vin-skeleton" style="height: 18px; width: 65%"></div>
    <div class="vin-skeleton vin-skeleton--text"></div>
    <div class="vin-skeleton vin-skeleton--text" style="width: 85%"></div>
    <div class="vin-skeleton" style="height: 36px; width: 110px; margin-top: 6px"></div>
  </div>
</div>

List

Repeat a row for a list. Vary the line widths so it looks like text.

skeleton-list.html
<div role="status" aria-label="Loading messages" style="display: grid; gap: 18px; width: 100%; max-width: 320px">
  <div style="display: flex; align-items: center; gap: 12px">
    <div class="vin-skeleton vin-skeleton--circle" style="width: 36px"></div>
    <div style="flex: 1; display: grid; gap: 8px">
      <div class="vin-skeleton vin-skeleton--text" style="width: 40%"></div>
      <div class="vin-skeleton vin-skeleton--text" style="width: 90%"></div>
    </div>
  </div>
  <div style="display: flex; align-items: center; gap: 12px">
    <div class="vin-skeleton vin-skeleton--circle" style="width: 36px"></div>
    <div style="flex: 1; display: grid; gap: 8px">
      <div class="vin-skeleton vin-skeleton--text" style="width: 55%"></div>
      <div class="vin-skeleton vin-skeleton--text" style="width: 75%"></div>
    </div>
  </div>
  <div style="display: flex; align-items: center; gap: 12px">
    <div class="vin-skeleton vin-skeleton--circle" style="width: 36px"></div>
    <div style="flex: 1; display: grid; gap: 8px">
      <div class="vin-skeleton vin-skeleton--text" style="width: 35%"></div>
      <div class="vin-skeleton vin-skeleton--text" style="width: 80%"></div>
    </div>
  </div>
</div>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add skeleton
React
import { Skeleton } from "@/components/vin/skeleton";
Vue
import Skeleton from "@/components/vin/skeleton.vue";
Svelte
import Skeleton from "$lib/components/vin/skeleton.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/skeleton.json, which every framework version is tested against.

PropValuesDefaultIn HTML
shapeblocktextcircleblockvin-skeleton--{value}
width / height
Size each shape like the content it replaces.
CSS size—style="width: …; height: …"

Parts

React, Vue, SvelteHTML classes
<Skeleton>.vin-skeleton.vin-skeleton--text.vin-skeleton--circle

Accessibility

  • Wrap the shapes in one element with role="status" and an aria-label ("Loading profile"), so screen readers hear one message, not a list of empty boxes.
  • Remove the skeleton when the content arrives; the real content takes its place.
  • The shimmer stops when the user asks for reduced motion.