import { Skeleton, SkeletonGroup } from "@senvenli/react/feedback";
import { Stack } from "@senvenli/react/layout";
const ROWS = ["first", "second", "third"];
export default function Example() {
return (
<SkeletonGroup label="Loading customers" isLoading>
<Stack space="space-200">
{ROWS.map((row) => (
<Stack direction="horizontal" key={row} space="space-150" wrap={false}>
<Skeleton variant="circle" size={32} />
<div className="min-w-0 flex-1">
<Skeleton variant="text" lines={2} />
</div>
</Stack>
))}
</Stack>
</SkeletonGroup>
);
}import { Skeleton, SkeletonGroup } from "@senvenli/react/feedback";Examples
Swapping in the content
`isLoaded` shows the children in place of the shape.import { Button } from "@senvenli/react/action";
import { Avatar, Text } from "@senvenli/react/display";
import { Skeleton, SkeletonGroup } from "@senvenli/react/feedback";
import { Stack } from "@senvenli/react/layout";
import { useState } from "react";
export default function Example() {
const [isLoading, setLoading] = useState(true);
return (
<Stack space="space-200" align="start">
<div className="w-full">
<SkeletonGroup label="Loading customer" loadedLabel="Customer" isLoading={isLoading}>
<Stack direction="horizontal" space="space-150" wrap={false}>
<Skeleton variant="circle" size={32} isLoaded={!isLoading}>
<Avatar name="Sofia Marin" src="/avatars/05.webp" />
</Skeleton>
<div className="min-w-0 flex-1">
<Skeleton variant="text" lines={2} isLoaded={!isLoading}>
<Stack>
<Text weight="medium">Sofia Marin</Text>
<Text size="body-small" tone="subtle">ada@example.com</Text>
</Stack>
</Skeleton>
</div>
</Stack>
</SkeletonGroup>
</div>
<Button onPress={() => setLoading((current) => !current)}>{isLoading ? "Show the content" : "Show the skeleton"}</Button>
</Stack>
);
}A card with a photo
`aspectRatio` holds the photo's box, and `radius` matches what it replaces.import { Skeleton, SkeletonGroup } from "@senvenli/react/feedback";
import { Box, Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<div className="mx-auto max-w-xs">
<SkeletonGroup label="Loading project" isLoading>
<Box padding="space-200" radius="large" border>
<Stack space="space-200">
<Skeleton aspectRatio="16/9" radius="large" />
<Skeleton width="50%" height={16} />
<Skeleton variant="text" lines={3} />
<Skeleton width={96} height={32} radius="medium" />
</Stack>
</Box>
</SkeletonGroup>
</div>
);
}Guidelines
When to use it
- A layout is loading and its shape is known.
Accessibility
Built in
- SkeletonGroup marks the region busy and announces when it has loaded.
You provide
- A
labelon SkeletonGroup that says what is loading.
API reference
Skeleton
| Prop | Type | Default | Description |
|---|---|---|---|
isLoaded | boolean | – | Shows the children instead of the shape once the data is there. |
children | React.ReactNode | – | |
delay | number | – | Milliseconds before the shape appears (default 300); the space is held meanwhile. |
variant | "text" | "circle" | "rectangle" | – |
|
lines | number | – |
|
size | number | – |
|
width | string | number | – | CSS width ("60%", 240); default full width. |
height | string | number | – | CSS height; default 12px (a text line). |
radius | "none" | "small" | "medium" | "large" | "full" | – | The radius of what it replaces: |
aspectRatio | string | – | Aspect ratio for photos ("16/9"). |
motion | ComponentMotion | – |
|
isLoadedbooleanShows the children instead of the shape once the data is there.
childrenReact.ReactNodedelaynumberMilliseconds before the shape appears (default 300); the space is held meanwhile.
variant"text" | "circle" | "rectangle"rectangle(default): a block ofwidth×height;text:linesof text, the last one shorter;circle: an avatar ofsizepx.linesnumbertext: the number of 12px lines (default 2).sizenumbercircle: the diameter in px (default 32, a list avatar).widthstring | numberCSS width ("60%", 240); default full width.
heightstring | numberCSS height; default 12px (a text line).
radius"none" | "small" | "medium" | "large" | "full"The radius of what it replaces:
mediumfor a button,largefor a card photo.aspectRatiostringAspect ratio for photos ("16/9").
motionComponentMotionauto(follow the device),reduceornone, for this component; the provider's setting otherwise.
SkeletonGroup
| Prop | Type | Default | Description |
|---|---|---|---|
labelRequired | string | – | What is loading ("Loading orders"); the region's name while busy. |
loadedLabel | string | – | The region's name once loaded ("Orders"); none by default. |
isLoadingRequired | boolean | – | |
childrenRequired | React.ReactNode | – |
labelRequiredstringWhat is loading ("Loading orders"); the region's name while busy.
loadedLabelstringThe region's name once loaded ("Orders"); none by default.
isLoadingRequiredbooleanchildrenRequiredReact.ReactNode