For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/v/0.6.0/en/components/skeleton.md.
  • English
  • Skeleton

    Show a content placeholder while loading.

    Basic usage

    Loading content
    Static placeholder
    basic.tsx
    import { Button, Flex, Skeleton, Space, Text } from '@ifhover/leaf-ui';
    
    import { useState } from 'react';
    
    export function SkeletonBasic() {
      const [loading, setLoading] = useState(true);
      return (
        <Space direction="vertical" align="stretch">
          <Button variant="outline" onClick={() => setLoading(!loading)}>
            Toggle loading
          </Button>
          <Flex direction="column" gap="sm">
            <Text>Loading content</Text>
            <Skeleton loading={loading} avatar rows={3} rowWidths={['100%', '85%', '55%']} round>
              <p>Project content is ready.</p>
            </Skeleton>
          </Flex>
          <Flex direction="column" gap="sm">
            <Text>Static placeholder</Text>
            <Skeleton active={false} title={false} rows={2} />
          </Flex>
        </Space>
      );
    }
    

    Skeleton API

    PropertyTypeDefaultDescription
    loading / activebooleantrueShow placeholder / animate
    avatar / roundbooleanfalseAvatar placeholder / round rows
    titlebooleantrueTitle placeholder
    titleWidthnumber | string'38%'Title width
    rowsnumber3Body rows, up to 20
    rowWidthsreadonly (number | string)[]—Widths of each row
    childrenReactNode—Loaded content

    Types

    Import the exported types when defining props or building item lists.

    import type { SkeletonProps } from '@ifhover/leaf-ui';

    Usage notes

    When loading is false, render children. Reduced motion preferences and ConfigProvider motion settings control the animation.