menumenu_openMDC

Skeleton

descriptionREADMEwidgetsDemo

Material Design 3 Expressive loading placeholder components with GPU-composited shimmer/pulse motion, zero-CLS content wrapping, and coordinated group context.

Variants & Options

  • SkeletonVariant: text (default), rectangular, rounded, circular, pill
  • SkeletonAnimation: shimmer (default), pulse, none
  • SkeletonSize: extra-small, small, medium (default), large, extra-large

Usage

Standalone Placeholders

<mdc-skeleton variant="circular" size="large"></mdc-skeleton>
<mdc-skeleton variant="text" lines="3" last-line-width="65%"></mdc-skeleton>
<mdc-skeleton variant="rounded" width="320px" aspect-ratio="16 / 9"></mdc-skeleton>

Zero-CLS Content Wrapper Mode

<mdc-skeleton loading variant="rounded">
    <mdc-card variant="outlined" style="padding: 16px;">
        <h3>Loaded Content</h3>
        <p>The skeleton inherits the exact dimensions of the wrapped content.</p>
    </mdc-card>
</mdc-skeleton>

Coordinated Group (<mdc-skeleton-group>)

<mdc-skeleton-group loading animation="shimmer" label="Loading profile">
    <mdc-skeleton variant="circular" size="large"></mdc-skeleton>
    <mdc-skeleton variant="text" lines="2"></mdc-skeleton>
</mdc-skeleton-group>

Animation

Code
<div style="display: grid; gap: 16px; width: 100%; max-width: 360px;">
    <div>
        <div style="margin-bottom: 6px; font-size: 12px; opacity: 0.72;">Shimmer (Default)</div>
        <mdc-skeleton variant="rounded" animation="shimmer" height="56px"></mdc-skeleton>
    </div>
    <div>
        <div style="margin-bottom: 6px; font-size: 12px; opacity: 0.72;">Pulse</div>
        <mdc-skeleton variant="rounded" animation="pulse" height="56px"></mdc-skeleton>
    </div>
    <div>
        <div style="margin-bottom: 6px; font-size: 12px; opacity: 0.72;">None (Static)</div>
        <mdc-skeleton variant="rounded" animation="none" height="56px"></mdc-skeleton>
    </div>
</div>

Group

Code
<div style="display: flex; flex-direction: column; gap: 16px; align-items: flex-start; width: 100%; max-width: 380px;">
    <mdc-button
        variant="filled-tonal"
        onclick="const g = this.getRootNode().querySelector('#demo-skeleton-group'); g.loading = !g.loading;"
    ><span>Toggle Group Loading</span></mdc-button>

    <mdc-skeleton-group id="demo-skeleton-group" loading animation="shimmer" label="Loading profile card" style="width: 100%;">
        <div style="display: flex; align-items: center; gap: 12px;">
            <mdc-skeleton variant="circular" size="large">
                <mdc-avatar name="Sandlada MDC" size="large" auto-color></mdc-avatar>
            </mdc-skeleton>
            <div style="flex: 1; display: flex; flex-direction: column; gap: 8px;">
                <mdc-skeleton variant="text" width="140px">
                    <div style="font-weight: 600; font-size: 16px;">Sandlada MDC</div>
                </mdc-skeleton>
                <mdc-skeleton variant="text" size="small" width="200px">
                    <div style="font-size: 13px; opacity: 0.72;">Material Design 3 Web Components</div>
                </mdc-skeleton>
            </div>
        </div>
        <mdc-skeleton variant="rounded">
            <div style="padding: 16px; border-radius: 12px; background: var(--md-sys-color-surface-container-low);">
                Coordinated group loading reveals all wrapped regions together while announcing a single accessible status.
            </div>
        </mdc-skeleton>
    </mdc-skeleton-group>
</div>

Lines

Code
<div style="width: 100%; max-width: 400px;">
    <mdc-skeleton variant="text" lines="4" last-line-width="55%"></mdc-skeleton>
</div>

Loading

Code
<div style="display: flex; flex-direction: column; gap: 16px; align-items: flex-start; width: 100%; max-width: 360px;">
    <mdc-button
        variant="filled-tonal"
        onclick="const s = this.getRootNode().querySelector('#wrapper-skeleton'); s.loading = !s.loading;"
    ><span>Toggle Loading</span></mdc-button>

    <mdc-skeleton id="wrapper-skeleton" loading variant="rounded" style="width: 100%;">
        <mdc-card variant="outlined" style="padding: 16px; width: 100%; box-sizing: border-box;">
            <div style="display: flex; align-items: center; gap: 12px;">
                <mdc-avatar name="Kai Orion" auto-color></mdc-avatar>
                <div>
                    <div style="font-weight: 600;">Zero-CLS Wrapper</div>
                    <div style="font-size: 13px; opacity: 0.72;">Skeleton matches wrapped card geometry.</div>
                </div>
            </div>
        </mdc-card>
    </mdc-skeleton>
</div>

Reload Cycle

Code
<div
    id="reload-cycle-demo"
    style="display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 420px;"
>
    <div style="display: flex; flex-wrap: wrap; align-items: center; gap: 8px;">
        <mdc-button
            variant="filled"
            onclick="
                const root = this.getRootNode();
                const group = root.querySelector('#cycle-group');
                const status = root.querySelector('#cycle-status');
                const title = root.querySelector('#cycle-title');
                const subtitle = root.querySelector('#cycle-subtitle');
                const body = root.querySelector('#cycle-body');
                const avatar = root.querySelector('#cycle-avatar');
                const count = (Number(group.dataset.cycle || 0) + 1);
                group.dataset.cycle = String(count);
                clearTimeout(Number(group.dataset.timerId || 0));
                group.loading = true;
                status.textContent = 'State: Skeleton (loading=true)';
                const timerId = setTimeout(() => {
                    avatar.name = count % 2 === 1 ? 'Kai Orion' : 'Sandlada MDC';
                    title.textContent = count % 2 === 1 ? 'Release v1.2.0 Published' : 'Design Tokens Updated';
                    subtitle.textContent = 'Fetched #' + count + ' · ' + new Date().toLocaleTimeString();
                    body.textContent = 'Transitioned smoothly from Skeleton back to Real DOM. Click Simulate Reload to return to Skeleton.';
                    group.loading = false;
                    status.textContent = 'State: Real DOM (loading=false)';
                }, 1200);
                group.dataset.timerId = String(timerId);
            "
        ><span>Simulate Reload (Skeleton → DOM → Skeleton)</span></mdc-button>

        <mdc-button
            variant="outlined"
            onclick="
                const root = this.getRootNode();
                const group = root.querySelector('#cycle-group');
                const status = root.querySelector('#cycle-status');
                clearTimeout(Number(group.dataset.timerId || 0));
                group.loading = !group.loading;
                status.textContent = group.loading ? 'State: Skeleton (loading=true)' : 'State: Real DOM (loading=false)';
            "
        ><span>Step Toggle</span></mdc-button>
    </div>

    <div id="cycle-status" style="font-size: 12px; opacity: 0.72;">State: Skeleton (loading=true)</div>

    <mdc-skeleton-group id="cycle-group" loading animation="shimmer" label="Loading feed item" style="width: 100%;">
        <mdc-card variant="outlined" style="padding: 16px; width: 100%; box-sizing: border-box;">
            <div style="display: flex; flex-direction: column; gap: 12px;">
                <div style="display: flex; align-items: center; gap: 12px;">
                    <mdc-skeleton variant="circular" size="medium">
                        <mdc-avatar id="cycle-avatar" name="Kai Orion" auto-color></mdc-avatar>
                    </mdc-skeleton>
                    <div style="flex: 1; display: flex; flex-direction: column; gap: 6px;">
                        <mdc-skeleton variant="text" width="180px">
                            <div id="cycle-title" style="font-weight: 600;">Release v1.2.0 Published</div>
                        </mdc-skeleton>
                        <mdc-skeleton variant="text" size="small" width="140px">
                            <div id="cycle-subtitle" style="font-size: 12px; opacity: 0.72;">Initial content</div>
                        </mdc-skeleton>
                    </div>
                </div>
                <mdc-skeleton variant="rounded">
                    <div id="cycle-body" style="font-size: 14px; line-height: 1.5;">
                        Click Simulate Reload or Step Toggle to cycle between Skeleton and Real DOM without layout shift.
                    </div>
                </mdc-skeleton>
            </div>
        </mdc-card>
    </mdc-skeleton-group>
</div>

Size

Code
<div style="display: flex; align-items: center; gap: 16px; flex-wrap: wrap;">
    <mdc-skeleton variant="circular" size="extra-small"></mdc-skeleton>
    <mdc-skeleton variant="circular" size="small"></mdc-skeleton>
    <mdc-skeleton variant="circular" size="medium"></mdc-skeleton>
    <mdc-skeleton variant="circular" size="large"></mdc-skeleton>
    <mdc-skeleton variant="circular" size="extra-large"></mdc-skeleton>
</div>

Variant

Code
<div style="display: grid; gap: 16px; width: 100%; max-width: 360px;">
    <mdc-skeleton variant="text"></mdc-skeleton>
    <mdc-skeleton variant="rectangular" height="72px"></mdc-skeleton>
    <mdc-skeleton variant="rounded" height="72px"></mdc-skeleton>
    <div style="display: flex; align-items: center; gap: 16px;">
        <mdc-skeleton variant="circular" size="large"></mdc-skeleton>
        <mdc-skeleton variant="pill" size="medium"></mdc-skeleton>
    </div>
</div>