On this page

Skeleton

Live examples of Skeleton, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.

A card

Shapes in the size of the avatar, the two lines and the note. The card says once that it is loading.

Loading customer
SkeletonCard.vue
<script setup lang="ts">
import { Skeleton } from '@/components/ui/skeleton'
</script>

<template>
  <!-- The card that is loading says so once (aria-busy and one line of hidden text); the skeleton shapes are hidden from screen readers. -->
  <div
    aria-busy="true"
    class="flex w-full max-w-80 flex-col gap-(--bh-space-150) rounded-(--bh-radius-card) border-(length:--bh-border-width-default) border-(--bh-color-border) bg-(--bh-color-surface) p-(--bh-space-200)"
  >
    <span class="sr-only">Loading customer</span>
    <div class="flex items-center gap-(--bh-space-150)">
      <Skeleton class="size-(--bh-size-control-large) rounded-(--bh-radius-full)" />
      <div class="flex flex-1 flex-col gap-(--bh-space-100)">
        <Skeleton class="h-(--bh-space-200) w-3/4" />
        <Skeleton class="h-(--bh-space-150) w-1/2" />
      </div>
    </div>
    <Skeleton class="h-(--bh-space-600) w-full" />
  </div>
</template>

Table rows

The real header and the same row height, so the table does not jump when the rows arrive.

Orders, loading
OrderCustomerTotal
SkeletonTable.vue
<script setup lang="ts">
import { Skeleton } from '@/components/ui/skeleton'

// Same row height and columns as the loaded table, so nothing shifts when the rows arrive.
const rows = 4
</script>

<template>
  <table aria-busy="true" class="w-full max-w-120 border-collapse [font:var(--bh-font-body-default)]">
    <caption class="sr-only">Orders, loading</caption>
    <thead>
      <tr class="border-b-(length:--bh-border-width-default) border-(--bh-color-border) text-start text-(--bh-color-text-subtle) [font:var(--bh-font-label-default)]">
        <th class="px-(--bh-space-table-cell-x) py-(--bh-space-table-cell-y) text-start">Order</th>
        <th class="px-(--bh-space-table-cell-x) py-(--bh-space-table-cell-y) text-start">Customer</th>
        <th class="px-(--bh-space-table-cell-x) py-(--bh-space-table-cell-y) text-end">Total</th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="row in rows" :key="row" class="border-b-(length:--bh-border-width-default) border-(--bh-color-border)">
        <td class="px-(--bh-space-table-cell-x) py-(--bh-space-table-cell-y)"><Skeleton class="h-(--bh-space-200) w-20" /></td>
        <td class="px-(--bh-space-table-cell-x) py-(--bh-space-table-cell-y)"><Skeleton class="h-(--bh-space-200) w-32" /></td>
        <td class="px-(--bh-space-table-cell-x) py-(--bh-space-table-cell-y)"><Skeleton class="ms-auto h-(--bh-space-200) w-16" /></td>
      </tr>
    </tbody>
  </table>
</template>