# Skeleton

## Usage

Import the component from its dedicated entry. The component loads its structural styles.

Import the theme in your application entry:

```ts
import '@astryx-vue/themes/neutral.css'
```

Component usage:

```vue
<script setup lang="ts">
import { Skeleton } from '@astryx-vue/core/Skeleton'
</script>

<template>
  <div aria-busy="true" aria-label="Loading content" role="status">
    <Skeleton :height="20" :width="200" />
  </div>
</template>
```

### Anatomy

- **Placeholder**: Painted shape that stands in for content while it loads.

## Best practices

| Guidance | Practices |
| --- | --- |
| Do | Match the size and shape of the content being loaded to create a realistic placeholder. |
| Do | Stagger multiple skeletons with the `index` prop for a natural wave animation. |
| Don't | Use when the content dimensions are unknown; use Spinner instead. |
| Don't | Combine with a Spinner on the same content area; pick one loading pattern. |
| Don't | Show skeletons indefinitely; if loading takes too long, show an error or empty state instead. |

## Examples

### Card loading

A card placeholder: a round avatar, a name, a short line, then a few lines of body text. index staggers the pulse.

```vue
<script setup lang="ts">
import { Card } from '@astryx-vue/core/Card'
import { Skeleton } from '@astryx-vue/core/Skeleton'
import { HStack, VStack } from '@astryx-vue/core/Stack'
</script>

<template>
  <Card :width="320">
    <VStack :gap="3">
      <HStack align="center" :gap="3">
        <Skeleton :height="40" :index="0" radius="rounded" :width="40" />
        <VStack :gap="1">
          <Skeleton :height="14" :index="1" :width="120" />
          <Skeleton :height="12" :index="2" :width="80" />
        </VStack>
      </HStack>
      <Skeleton :height="14" :index="3" width="100%" />
      <Skeleton :height="14" :index="4" width="90%" />
      <Skeleton :height="14" :index="5" width="75%" />
    </VStack>
  </Card>
</template>
```

### Staggered list

Horizontal bars of different widths, standing in for a list that has not loaded yet.

```vue
<script setup lang="ts">
import { Skeleton } from '@astryx-vue/core/Skeleton'
import { VStack } from '@astryx-vue/core/Stack'
</script>

<template>
  <VStack :gap="2">
    <Skeleton :height="16" :index="0" :width="300" />
    <Skeleton :height="16" :index="1" :width="280" />
    <Skeleton :height="16" :index="2" :width="320" />
    <Skeleton :height="16" :index="3" :width="260" />
    <Skeleton :height="16" :index="4" :width="290" />
  </VStack>
</template>
```

### Table rows

Four columns per row, with widths that follow the content, and a pulse that steps forward by index.

```vue
<script setup lang="ts">
import { Skeleton } from '@astryx-vue/core/Skeleton'
import { HStack, VStack } from '@astryx-vue/core/Stack'
</script>

<template>
  <VStack :gap="2">
    <HStack v-for="row in 4" :key="row" align="center" :gap="4">
      <Skeleton :height="16" :index="(row - 1) * 4" :width="50" />
      <Skeleton :height="16" :index="(row - 1) * 4 + 1" :width="180" />
      <Skeleton :height="16" :index="(row - 1) * 4 + 2" :width="100" />
      <Skeleton :height="16" :index="(row - 1) * 4 + 3" :width="80" />
    </HStack>
  </VStack>
</template>
```

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `width` | `number \| string` | `'100%'` | Placeholder width. Numbers are interpreted as pixels. Strings are preserved as CSS dimensions. |
| `height` | `number \| string` | `'100%'` | Placeholder height. Numbers are interpreted as pixels. Strings are preserved as CSS dimensions. |
| `radius` | `'none' \| 0 \| 1 \| 2 \| 3 \| 4 \| 'rounded'` | `3` | Design-token radius step. Use `none` for square corners and `rounded` for a fully rounded shape. |
| `index` | `number` | `0` | Stagger index. Each increment delays the animation by 100ms. |

## Accessibility

- `Skeleton` sets `aria-hidden="true"` by default.
- Assistive technology does not read the default placeholders.
- Give the surrounding loading region an accessible name.
- Set `aria-busy="true"` on that region.
- If the system requests reduced motion, the pulse animation stops.
- In forced-colors mode, placeholders remain visible.

## Native attributes

The root element is `<div>`.

The root element receives:

- HTML attributes.
- `aria-*` attributes.
- `data-*` attributes.
- `class`.
- `style`.
- Native event listeners.

An explicit `aria-hidden` value overrides the default.
