Skip to main content

Skeleton

BasicData display<co-skeleton>

Skeleton shows grey placeholder shapes while content loads.

import { Skeleton } from 'health-components';

Examples​

Showcase​

Storybook

Rows​

Storybook

Card Placeholder​

Storybook

Avatar​

Storybook

Usage​

{loading ? <Skeleton variant="row" rows={5} /> : <PatientRows />}

When to use​

  • Loads over about 300ms where the layout is known: table rows, cards, KPI values.

When not to use​

  • Actions that run after a click: Button loading.

Variants and states​

VariantWhat it is
textOne or more lines; the last is shorter.
rowTable-like rows with an avatar circle.
cardA card placeholder.
avatarCircle.

Accessibility​

  • aria-busy with a label; the pulse stops under prefers-reduced-motion.

Do and don't​

  • Do: Match the shape of the content that will load.
  • Don't: Skeletons for more than a few seconds: show progress or an error.

Props​

PropTypeDefaultDescription
variantSkeletonVariant'text''text' | 'row' | 'card' | 'avatar'
linesnumber1Text lines (variant text); the last line is shorter
rowsnumber3Table rows (variant row)
widthCSSProperties['width']'100%'CSS width of text lines
labelstring"Loading" ("Loading rows" for variant row)Accessible name (aria-label)

Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, onChange, onInput, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-skeleton>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-skeleton variant="…" lines="…" [width]="width" (co-change)="onChange($event.detail)"></co-skeleton>
KindNameDescription
attributevariant'text' | 'row' | 'card' | 'avatar'; default 'text'
attributelinesText lines (variant text); the last line is shorter; default 1
attributerowsTable rows (variant row); default 3
property / JSON attributewidthCSS width of text lines; default '100%'
attributelabelAccessible name (aria-label); default "Loading" ("Loading rows" for variant row)
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-change (React: onChange)
eventco-input (React: onInput)