---
title: "States"
description: "Loading, content, empty responses and errors."
canonical_url: "https://kukson777.github.io/boneprint/docs/guide/states"
---
# States

> Loading, content, empty responses and errors.

<states-demo>



</states-demo>

## 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`.

<table>
<thead>
  <tr>
    <th>
      What arrived
    </th>
    
    <th>
      What's shown
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      no data yet, or <code>
        []
      </code>
      
       while the request is still on its way
    </td>
    
    <td>
      the skeleton
    </td>
  </tr>
  
  <tr>
    <td>
      an error
    </td>
    
    <td>
      the <code>
        #error
      </code>
      
       slot
    </td>
  </tr>
  
  <tr>
    <td>
      a successful <code>
        null
      </code>
      
       or <code>
        []
      </code>
    </td>
    
    <td>
      the <code>
        #empty
      </code>
      
       slot
    </td>
  </tr>
  
  <tr>
    <td>
      data
    </td>
    
    <td>
      the default slot
    </td>
  </tr>
</tbody>
</table>

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`.

<code-preview>
<suspense-demo>



</suspense-demo>

<template v-slot:code="">

```vue
<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>
```

</template>
</code-preview>


## Sitemap

See the full [sitemap](https://kukson777.github.io/boneprint/sitemap.md) for all pages.
