Skeleton

July 6, 2026 · View on GitHub

Placeholder shown while real content loads. Six shape presets (line, circle, rectangle, avatar, button, card) plus a size ramp cover the common patterns. Animated shimmer is on by default.

Contract

<kp-skeleton> renders a single grey-toned placeholder with an optional animated shimmer (linear gradient that sweeps horizontally). Six shape presets give you ready-made compositions for most situations; for anything custom, compose multiple line/circle/rectangle skeletons into your own shape.

Shapes

ShapeUseNotes
lineText lineDefault. Override [width] to match real content
circleAvatar / round iconAspect 1:1, fixed per size
rectangleImage / chart / heroFixed aspect per size
avatarAvatar row (circle + 2 lines)Composite preset
buttonButton placeholderMatches Kanso button sizes
cardCard (image + title + 2 lines)Composite preset, fixed 320 wide

Sizes

SizeLine heightCircleRectangleButton (w×h)
xs824120×8080×24
sm1232200×12096×28
md1640320×200112×36
lg2056480×300120×44
xl2472640×400128×52

API

Inputs

NameTypeDefaultDescription
shape'line' | 'circle' | 'rectangle' | 'avatar' | 'button' | 'card''line'Visual preset
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Size ramp
animatedbooleantrueToggle the shimmer animation
widthstring | nullnullWidth override (e.g. '80%', '240px') — useful for line shapes
heightstring | nullnullHeight override for custom layouts

Accessibility

  • Host is aria-hidden="true" — skeleton is purely visual and shouldn't be announced by screen readers. Content that replaces the skeleton should be announced when it loads (use aria-live on the container).
  • The shimmer respects prefers-reduced-motion when the root document sets the standard media query (browsers pause CSS animations automatically in that mode).

Do / Don't

Do

  • Match the skeleton shape to the content it's replacing. Don't show a card skeleton where a paragraph will load.
  • Keep skeletons fast — aim for sub-second transitions to real content.
  • Use width overrides on line skeletons to approximate real line lengths (paragraphs look better with mixed widths).

Don't

  • Don't show skeletons for < 200ms operations — they cause flash / layout shift.
  • Don't animate when the user disabled motion. The shimmer is already opt-outable via prefers-reduced-motion; don't add additional movement.
  • Don't replace empty states with skeletons. If there's genuinely no data (not loading), use <kp-empty-state>.

References

Changelog

  • 0.1.0 — Initial release. Six shape presets, five-size ramp, animated shimmer toggle.