Skip to content
iv-ui v0.3.0

Skeleton

since 0.2.0

A pulsing placeholder that holds the shape of loading content.

import { Skeleton } from '@elluzion/iv-ui';

Shapes

Rectangle, text line, and circle placeholders.

Source· svelte Show Hide
<script lang="ts">
	import { Skeleton } from '@elluzion/iv-ui';
</script>

<div class="stack">
	<Skeleton shape="rect" height={72} />
	<Skeleton shape="line" />
	<Skeleton shape="line" width="70%" />
	<Skeleton shape="circle" />
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-md);
		width: 100%;
		max-width: 320px;
	}
</style>
  • shape picks rect, line, or circle; width and height accept numbers or CSS lengths.
  • Match the dimensions of the content that replaces it to avoid layout shift.
  • Combine several skeletons to sketch a list or card while data loads.

Card placeholder

A composition that mirrors the final card layout.

Source· svelte Show Hide
<script lang="ts">
	import { Card, Skeleton } from '@elluzion/iv-ui';
</script>

<Card padding="lg">
	<div class="head">
		<Skeleton shape="circle" width={32} height={32} />
		<div class="meta">
			<Skeleton shape="line" width="45%" />
			<Skeleton shape="line" width="30%" />
		</div>
	</div>
	<Skeleton shape="line" />
	<Skeleton shape="line" width="85%" />
	<Skeleton shape="line" width="60%" />
</Card>

<style>
	.head {
		display: flex;
		align-items: center;
		gap: var(--iv_spacing-md);
		margin-bottom: var(--iv_spacing-lg);
	}

	.meta {
		display: flex;
		flex: 1;
		flex-direction: column;
		gap: var(--iv_spacing-xs);
	}
</style>
import { Skeleton } from '@elluzion/iv-ui';

Props

4 props · 0 events · 0 snippets
PropTypeDefaultDescription
shape 'rect' | 'line' | 'circle''rect'Visual shape of the placeholder.
width string | number—Width; numbers are treated as pixels.
height string | number—Height; numbers are treated as pixels.
className string''Extra classes merged onto the root element.
  • Skeletons are hidden from assistive technology.
  • The pulse stops when prefers-reduced-motion is set.
  • Announce loading elsewhere, for example with role="status" or an Alert.
Class hooks
.iv-circle.iv-line.iv-rect.iv-skeleton
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records