PPolaris ComponentsConnect an agent

Skeleton display text

A placeholder block that stands in for a heading or a headline metric while the page loads, in four sizes.

Preview

Code

Example.jsx
import { Card, Box, BlockStack, InlineGrid, SkeletonDisplayText, SkeletonBodyText, Divider } from '@shopify/polaris';

const STAT_TILES = ['sessions', 'orders', 'revenue'];

const SIZE_EXAMPLES = [
  { id: 'small', size: 'small' },
  { id: 'medium', size: 'medium' },
  { id: 'large', size: 'large' },
  { id: 'extraLarge', size: 'extraLarge' },
];

const GRID_COLUMNS = { xs: 1, sm: 3 };

export const Example = () => (
  <BlockStack gap="400">
    <InlineGrid columns={GRID_COLUMNS} gap="400">
      {STAT_TILES.map((tile) => (
        <Card key={tile}>
          <BlockStack gap="300">
            <Box maxWidth="120px">
              <SkeletonBodyText lines={1} />
            </Box>
            <SkeletonDisplayText size="large" maxWidth="80%" />
            <Box maxWidth="80px">
              <SkeletonBodyText lines={1} />
            </Box>
          </BlockStack>
        </Card>
      ))}
    </InlineGrid>

    <Card>
      <BlockStack gap="400">
        {SIZE_EXAMPLES.map((item, index) => (
          <BlockStack key={item.id} gap="400">
            {index > 0 && <Divider />}
            <SkeletonDisplayText size={item.size} maxWidth="60%" />
          </BlockStack>
        ))}
      </BlockStack>
    </Card>
  </BlockStack>
);