Skip to content

Configuration & theming

Component props

Everything you pass to <AutoSkeleton>:

PropTypeDefaultDescription
loadingboolean— (required)Show the skeleton when true, the real content when false.
idstringderivedCache identity. Defaults to the wrapped component's name; set it when names may be minified in production, or to segregate a cache entry.
countnumber1Repeat the captured block N times — for lists whose length isn't known while loading.
animatedbooleanglobalPlay the shimmer for this instance (overrides the global default).
baseColor / highlightColor / radius / durationstringglobalPer-instance theme overrides (see below).

Global defaults

Pass options to createAutoSkeleton() to set defaults for every <AutoSkeleton> in your app:

ts
app.use(
  createAutoSkeleton({
    baseColor: '#e2e5e9',
    highlightColor: '#f2f4f7',
    radius: '4px',
    duration: '1.5s',
    animation: true,
  }),
)
OptionTypeDefaultDescription
baseColorstring#e2e5e9Base fill of skeleton blocks.
highlightColorstring#f2f4f7Color of the moving shimmer band.
radiusstring4pxBorder radius for media/box primitives (text is always pill-shaped).
durationstring1.5sTime for one full shimmer sweep. Lower = faster.
animationbooleantrueWhether the shimmer plays at all.

See Caching & persistence for the caching-related options (persist, version, maxAge, maxEntries, widthStep).

Per-instance overrides

Any theme value can be overridden on a single <AutoSkeleton>, which wins over the global default:

vue
<AutoSkeleton :loading="loading" base-color="#dfe6ff" duration="0.9s">
  <PromoBanner />
</AutoSkeleton>

Turning the animation off

The shimmer is on by default. Disable it globally or per-instance for a static gray placeholder:

ts
// globally
app.use(createAutoSkeleton({ animation: false }))
vue
<!-- per instance -->
<AutoSkeleton :loading="loading" :animated="false">
  <UserCard :user="user" />
</AutoSkeleton>

Reduced motion is automatic

The shimmer is disabled automatically for users whose OS has prefers-reduced-motion: reduce — you don't need to handle that yourself.

Theming with CSS variables

Under the hood the options set CSS custom properties on the wrapper. You can also set them in your own CSS for finer control (e.g. dark mode):

css
.as-root {
  --as-base: #2a2a2e;
  --as-highlight: #3a3a40;
  --as-radius: 6px;
  --as-duration: 1.5s;
}
VariableMaps to
--as-basebaseColor
--as-highlighthighlightColor
--as-radiusradius
--as-durationduration

Released under the MIT License.