Skeleton
A placeholder component that displays a loading animation while content is being fetched or rendered.
Anatomy
<script>
import {
Skeleton,
SkeletonCircle,
SkeletonText,
} from "@saas-ui/svelte/components/skeleton";
</script>
<Skeleton height="20px" width="100%" />
<SkeletonCircle size="40px" />
<SkeletonText lines={3} />Examples
Basic Accessibility
<Skeleton height="1.25rem" width="200px" /> Circle Sizes Accessibility
size prop on SkeletonCircle to control the circle dimensions.
<Group gap={4} class="items-center">
{#each skeletonCircleSizes as size}
<SkeletonCircle {size} />
{/each}
</Group> Composite Accessibility
<Group gap={5} class="items-center">
<SkeletonCircle size="12" />
<Stack gap={2} class="flex-1">
<Skeleton height="1.25rem" />
<Skeleton height="1.25rem" width="80%" />
</Stack>
</Group> Content Loading Accessibility
<Stack gap={4} class="items-start">
<Skeleton {loading}>
<Text>Saas UI is cool</Text>
</Skeleton>
<Button size="sm" onclick={() => (loading = !loading)}>Toggle</Button>
</Stack> Feed Accessibility
<Stack gap={6} class="max-w-xs">
<Group gap={2} class="w-full items-center">
<SkeletonCircle size="10" />
<SkeletonText noOfLines={2} class="w-full" />
</Group>
<Skeleton height="200px" />
</Stack> Text Accessibility
SkeletonText for multi-line text placeholders.
<SkeletonText noOfLines={3} gap={4} /> Text Lines Accessibility
lines prop on SkeletonText to control the number of text lines.
<Stack gap={6}>
{#each [1, 2, 3, 4] as noOfLines}
<Stack gap={2}>
<Text size="xs" class="text-fg-muted"
>{noOfLines} line{noOfLines> 1 ? "s" : ""}</Text>
<SkeletonText {noOfLines} gap={2} />
</Stack>
{/each}
</Stack> Variants Accessibility
variant prop to change the animation style.
<Stack gap={5}>
<Group gap={5} class="items-center">
<Text class="w-[8ch]">pulse</Text>
<Skeleton class="flex-1" height="1.25rem" variant="pulse" />
</Group>
<Group gap={5} class="items-center">
<Text class="w-[8ch]">shine</Text>
<Skeleton class="flex-1" height="1.25rem" variant="shine" />
</Group>
</Stack> With Children Accessibility
<Group gap={4} class="items-center">
<Skeleton loading={true}>
<Badge>Select</Badge>
</Skeleton>
<Skeleton loading={false}>
<Badge>Select</Badge>
</Skeleton>
</Group>Props
| Prop | Type | Default | Description |
|---|---|---|---|
loading | boolean | true | Whether to show the skeleton loading state. |
variant | pulse | shine | none | pulse | The animation variant. |
height | text | - | The height of the skeleton. |
width | text | - | The width of the skeleton. |
class | text | - | CSS class to apply to the component. |