Skeleton

stable 0.8 kB
<hk-skeleton>

Placeholders shaped like the content they stand in for, so the layout does not shift when data lands. Three motions: a travelling sheen, a soft pulse, or none at all.

#loading#placeholder
In the package npm i hellskitchen-ui Import hk-skeleton and use it directly.

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
loadingbooleantrueOn hk-skeleton. Shows its hk-skeleton-line / hk-skeleton-circle children; projects the rest (the real content) when false.
motion'shimmer' | 'pulse' | 'none''shimmer'How the placeholder animates. Set on hk-skeleton it is inherited by every placeholder inside.
width / heightstring'100%' / '1em'On hk-skeleton-line. Box size. Match the real element to avoid a shift.
sizestring'2.5rem'On hk-skeleton-circle. Diameter.
radiusstring'0.375rem'On hk-skeleton-line. Corner radius.
linesnumber1On hk-skeleton-line. Repeats the line, tapering the last one.

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-skeleton-base#e8ecf1Placeholder fill.
--hk-skeleton-sheen#f6f8faColour of the travelling highlight.
--hk-skeleton-speed1.4sSweep duration.

Accessibility

  • The container is aria-busy while loading, so assistive tech knows content is pending rather than missing.
  • Placeholders are aria-hidden — a screen reader should hear "loading", not a dozen empty boxes.
  • prefers-reduced-motion drops to the static box rather than a slowed-down animation.

More in Feedback