Installation
Install the dependencies
pnpm add cn class-variance-authorityCopy the component
Copy the following files into src/lib/components/ui/skeleton.
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from 'cn';
let { children, class: classProp, ...props }: HTMLAttributes<HTMLDivElement> = $props();
</script>
<div data-slot="skeleton" {...props} class={cn('bg-muted rounded-md animate-pulse', classProp)}>
{@render children?.()}
</div>export { default as Skeleton } from './Skeleton.svelte';Update the import paths
Change the imports to match your project setup.
Usage
<script lang="ts">
import { Skeleton } from '$lib/components/ui/skeleton';
</script><Skeleton class="h-5 w-24 rounded-full" />