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, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/en/components/skeleton.md.

Skeleton

Show a content placeholder while loading.

Basic usage

Show the default skeleton placeholder while content is loading.

basic.tsx
import { Skeleton } from '@ifhover/leaf-ui';

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

Examples

Show loaded content

Your application controls loading. Children are not rendered while loading; they appear when loading becomes false. Use Loading instead if the existing content must remain mounted.

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>
  );
}

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
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>
  );
}

Row count and widths

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

rows.tsx
import { Skeleton } from '@ifhover/leaf-ui';

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

API

Skeleton API

Configure placeholder rows, shapes and animation.

PropertyTypeDefaultDescription
loadingbooleantrueShow placeholders; children render only when false.
activebooleantrueAnimate the placeholders.
avatarbooleanfalseShow an avatar placeholder.
titlebooleantrueTitle placeholder
titleWidthnumber | string'38%'Title width
rowsnumber3Body rows, up to 20
rowWidthsreadonly (number | string)[]—Widths of each row
roundbooleanfalseUse pill-shaped title and body placeholders; the avatar is unchanged.
childrenReactNode—Content shown after loading finishes.