Liking cljdoc? Tell your friends :D

x-skeleton

A stateless loading-placeholder component that renders an animated skeleton shape while content is being fetched or computed.

Registration

import { init } from '@vanelsas/baredom/x-skeleton';
init();

Basic usage

<!-- Default: full-width rect, pulse animation -->
<x-skeleton></x-skeleton>

<!-- Single text line -->
<x-skeleton variant="text"></x-skeleton>

<!-- Circle avatar placeholder -->
<x-skeleton variant="circle" width="40px" height="40px"></x-skeleton>

<!-- Explicit size -->
<x-skeleton height="120px"></x-skeleton>

<!-- Wave animation -->
<x-skeleton animation="wave" height="2rem"></x-skeleton>

<!-- No animation -->
<x-skeleton animation="none"></x-skeleton>

API

Tag name

x-skeleton

Observed attributes

AttributeTypeValuesDefaultDescription
variantstringrect | text | circlerectShape of the placeholder.
animationstringpulse | wave | nonepulseAnimation style. none renders a static placeholder.
widthstringAny CSS length valueExplicit width applied as inline style on the base.
heightstringAny CSS length valueExplicit height applied as inline style on the base.

Invalid values for variant and animation silently fall back to the default.

Properties

All properties reflect to their corresponding attribute.

PropertyTypeReflectsDefault
variantstringvariant"rect"
animationstringanimation"pulse"
widthstringwidth""
heightstringheight""

Setting a property to an empty string removes the attribute.

Events

None.

Slots

None. The component is purely presentational.

Shadow parts

PartElementDescription
basedivThe visible skeleton shape. Carries animation.
shimmerdivGradient overlay used by the wave animation.

CSS custom properties

PropertyDefault (light)Default (dark)Description
--x-skeleton-colorrgba(0,0,0,0.08)rgba(255,255,255,0.10)Base fill color of the placeholder.
--x-skeleton-highlightrgba(255,255,255,0.65)rgba(255,255,255,0.18)Gradient highlight for wave animation.
--x-skeleton-border-radius4px4pxCorner radius (overridden to 50% for circle, 3px for text).
--x-skeleton-duration1.5s1.5sDuration of the pulse or wave cycle.

Default sizing

VariantDefault widthDefault height
rect100%1rem
text100%1em
circle2.5rem2.5rem

Use the width and height attributes (or CSS) to override.

Animations

pulse (default)

The base element fades its opacity from 1 → 0.4 → 1 on a loop. Works for all variants.

wave

A bright gradient sweeps left-to-right across the base via the [part=shimmer] overlay. Suitable for wide rect or text placeholders.

none

No animation. The placeholder is fully static.

Accessibility

aria-hidden="true" is set automatically on the host element. Skeleton placeholders carry no semantic meaning; screen readers should rely on the surrounding UI context (e.g., aria-busy="true" on a container) to communicate loading state.

Theming

<!-- Custom purple skeleton -->
<x-skeleton
  height="80px"
  style="
    --x-skeleton-color: #ede9fe;
    --x-skeleton-highlight: rgba(139,92,246,0.25);
    --x-skeleton-border-radius: 8px;
  ">
</x-skeleton>

Light / dark mode

Default colors adapt automatically via @media (prefers-color-scheme: dark) inside the shadow stylesheet. Override with CSS custom properties if you manage your own color scheme.

Reduced motion

Both pulse and wave animations are disabled when @media (prefers-reduced-motion: reduce) is active. The placeholder remains visible as a static block.

Composition examples

Card skeleton

<div style="display:flex;gap:12px;align-items:center;">
  <x-skeleton variant="circle" width="48px" height="48px"></x-skeleton>
  <div style="flex:1;display:flex;flex-direction:column;gap:6px;">
    <x-skeleton variant="text" width="60%"></x-skeleton>
    <x-skeleton variant="text" width="40%"></x-skeleton>
  </div>
</div>
<x-skeleton height="120px" style="margin-top:12px;"></x-skeleton>

Table row skeleton

<div style="display:grid;grid-template-columns:1fr 2fr 1fr;gap:8px;">
  <x-skeleton variant="text"></x-skeleton>
  <x-skeleton variant="text"></x-skeleton>
  <x-skeleton variant="text" width="50%"></x-skeleton>
</div>

Normalization rules

  • variant: any value not in {"rect","text","circle"}"rect"
  • animation: any value not in {"pulse","wave","none"}"pulse"
  • width / height: empty string or absent → no inline style (variant default applies)

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close