Guide

States

Loading, content, empty responses and errors.

What the component decides

With :of, the state comes from the result of useFetch, useAsyncData or TanStack Query's useQuery: anything with data, status and error.

What arrivedWhat's shown
no data yet, or [] while the request is still on its waythe skeleton
an errorthe #error slot
a successful null or []the #empty slot
datathe default slot

An empty list before the answer is the data layer's placeholder, as with default: () => [] or data ?? []. The skeleton is drawn from sample or memory then, not from that list. The same goes for [] passed to :data together with :loading.

Refreshing

refresh() doesn't flash the skeleton: the old data stays on screen until the new data arrives. If you do want a skeleton, pass :loading.

Setting the state by hand

Set the state by hand with data, loading, empty and error. With immediate: false, pass :empty until you call execute().

The reveal event fires when content has replaced the skeleton.

With Suspense

A child component that awaits in setup has no data to pass to <Skeleton>. <SkeletonSuspense> is a Suspense boundary with a measured fallback: the component goes in the default slot, and markup rendered from sample data goes in #skeleton.

<template>
  <SkeletonSuspense label="Loading post">
    <AsyncPost />

    <template #skeleton>
      <h4>A title of about this length</h4>

      <p>The sample text stands in for the post until it loads.</p>
    </template>
  </SkeletonSuspense>
</template>