> Leaf UI 0.17.3 · Package: @ifhover/leaf-ui · Source: c3221834f84f2f48481a2054026b713456f8e5dc
> Browser documentation: https://ifhover.github.io/leaf-ui/en/components/skeleton.html

> For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/en/llms-full.txt.

# Skeleton

Show a content placeholder while loading.


## Basic usage

Show the default skeleton placeholder while content is loading.


basic.tsx

Copy code

```tsx lineNumbers file="../../../src/examples/en/skeleton/basic.tsx"
import { Skeleton } from '@ifhover/leaf-ui';

export function SkeletonBasic() {
  return <Skeleton />;
}
```

Expand code


## Examples

### Show loaded content

Your application controls `loading`. Children are not rendered while loading; they appear when `loading` becomes `false`. Use [Loading](https://ifhover.github.io/leaf-ui/en/components/loading.md) instead if the existing content must remain mounted.


Show content

content.tsx

Copy code

```tsx lineNumbers file="../../../src/examples/en/skeleton/content.tsx"
import { Button, Flex, Skeleton, Text } from '@ifhover/leaf-ui';
import { useState } from 'react';

export function SkeletonContent() {
  const [loading, setLoading] = useState(true);

  return (
    <Flex direction="column" gap="md">
      <Flex>
        <Button onClick={() => setLoading((value) => !value)}>
          {loading ? 'Show content' : 'Show placeholder'}
        </Button>
      </Flex>
      <Skeleton loading={loading}>
        <Text>Project content is ready.</Text>
      </Skeleton>
    </Flex>
  );
}
```

Expand code

### Avatar and rounded rows

Use `avatar` for an avatar placeholder. `round` rounds the title and body rows; it does not change the avatar.


Default rows

Rounded rows

shapes.tsx

Copy code

```tsx lineNumbers file="../../../src/examples/en/skeleton/shapes.tsx"
import { Flex, Skeleton, Text } from '@ifhover/leaf-ui';

export function SkeletonShapes() {
  return (
    <Flex direction="column" gap="lg">
      <Flex direction="column" gap="sm">
        <Text tone="muted">Default rows</Text>
        <Skeleton avatar />
      </Flex>
      <Flex direction="column" gap="sm">
        <Text tone="muted">Rounded rows</Text>
        <Skeleton avatar round />
      </Flex>
    </Flex>
  );
}
```

Expand code

### Row count and widths

Set `rows` for the number of body rows and `rowWidths` for their widths. Unspecified widths retain the default.


rows.tsx

Copy code

```tsx lineNumbers file="../../../src/examples/en/skeleton/rows.tsx"
import { Skeleton } from '@ifhover/leaf-ui';

export function SkeletonRows() {
  return <Skeleton rows={4} rowWidths={['100%', '80%', '90%', '60%']} />;
}
```

Expand code


## API

### Skeleton API

Configure placeholder rows, shapes and animation.

| Property     | Type                            | Default | Description                                                           |
| ------------ | ------------------------------- | ------- | --------------------------------------------------------------------- |
| `loading`    | `boolean`                       | `true`  | Show placeholders; children render only when false.                   |
| `active`     | `boolean`                       | `true`  | Animate the placeholders.                                             |
| `avatar`     | `boolean`                       | `false` | Show an avatar placeholder.                                           |
| `title`      | `boolean`                       | `true`  | Title placeholder                                                     |
| `titleWidth` | `number \| string`              | `'38%'` | Title width                                                           |
| `rows`       | `number`                        | `3`     | Body rows, up to 20                                                   |
| `rowWidths`  | `readonly (number \| string)[]` | —       | Widths of each row                                                    |
| `round`      | `boolean`                       | `false` | Use pill-shaped title and body placeholders; the avatar is unchanged. |
| `children`   | `ReactNode`                     | —       | Content shown after loading finishes.                                 |
