# Skeleton

Source: https://ecosphere.dev/docs/data/skeleton (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

Loading placeholders that mirror the real layout, and the loading region that holds them.

`import { EcoSkeleton } from "vue-ecosphere"`

## Rows

Shape the skeleton like the content it stands in for: rows for a list.

Vue (vue-ecosphere):

```vue
<EcoSkeleton shape="row" :count="3" />
```

React (react-ecosphere):

```tsx
<EcoSkeleton shape="row" count={3} />
```

## Bars

Bars for figures and text.

Vue (vue-ecosphere):

```vue
<div style="display:flex;flex-direction:column;gap:10px">
  <EcoSkeleton width="120px" height="11px" />
  <EcoSkeleton width="72px" height="32px" />
  <EcoSkeleton shape="lines" :count="2" />
</div>
```

React (react-ecosphere):

```tsx
<div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
  <EcoSkeleton width="120px" height="11px" />
  <EcoSkeleton width="72px" height="32px" />
  <EcoSkeleton shape="lines" count={2} />
</div>
```

## Loading a view

One role="status" per loading region, named with what is loading. Set aria-busy on the region being replaced, and show exactly one of loading, error, empty or content at a time.

Vue (vue-ecosphere):

```vue
<div aria-busy="true">
  <EcoSkeleton shape="row" :count="3" heading label="Loading invoices…" />
</div>
```

React (react-ecosphere):

```tsx
<div aria-busy="true">
  <EcoSkeleton shape="row" count={3} heading label="Loading invoices…" />
</div>
```

## Inside a card

loading--inline drops the padding and starts with a visible line saying what is loading, so no hidden status text is needed.

Vue (vue-ecosphere):

```vue
<div class="card__body" aria-busy="true">
  <EcoSkeleton layout="inline" label="Loading charges for this invoice…" height="32px" :count="3" />
</div>
```

React (react-ecosphere):

```tsx
<div className="card__body" aria-busy="true">
  <EcoSkeleton layout="inline" label="Loading charges for this invoice…" height="32px" count={3} />
</div>
```

## One line, in a form

40px high, so it occupies the space of the control it stands in for.

Vue (vue-ecosphere):

```vue
<EcoSkeleton layout="line" label="Loading cost centres…" />
```

React (react-ecosphere):

```tsx
<EcoSkeleton layout="line" label="Loading cost centres…" />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `shape` | `"bar" \| "circle" \| "row" \| "lines"` | "bar" | Rows for a list, bars for a table, lines for text. |
| `count` | `number` | 1 | How many rows, lines or bars. |
| `width / height` | `string` | — | CSS size of a bar or circle. |
| `onfill` | `boolean` | false | For a skeleton on a filled ground (skel--onfill). |
| `label` | `string` | — | What is loading. Makes it the loading region: role="status", named with these words. |
| `layout` | `"block" \| "inline" \| "line"` | "block" | Whole region (hidden status text), inside a card or section (visible body-sm line), or one form field. |
| `heading` | `boolean` | false | In a block, lead with a 24px heading bar about 35% wide. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `shape` | `"bar" \| "circle" \| "row" \| "lines"` | "bar" | Rows for a list, bars for a table, lines for text. |
| `count` | `number` | 1 | How many rows, lines or bars. |
| `width / height` | `string` | — | CSS size of a bar or circle. |
| `onfill` | `boolean` | false | For a skeleton on a filled ground (skel--onfill). |
| `label` | `string` | — | What is loading. Makes it the loading region: role="status", named with these words. |
| `layout` | `"block" \| "inline" \| "line"` | "block" | Whole region (hidden status text), inside a card or section (visible body-sm line), or one form field. |
| `heading` | `boolean` | false | In a block, lead with a 24px heading bar about 35% wide. |
