Skeleton
BasicData display
<co-skeleton>Skeleton shows grey placeholder shapes while content loads.
import { Skeleton } from 'health-components';
Examples
Showcase
Rows
Card Placeholder
Avatar
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
| Variant | What it is |
|---|---|
| text | One or more lines; the last is shorter. |
| row | Table-like rows with an avatar circle. |
| card | A card placeholder. |
| avatar | Circle. |
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
| Prop | Type | Default | Description |
|---|---|---|---|
variant | SkeletonVariant | 'text' | 'text' | 'row' | 'card' | 'avatar' |
lines | number | 1 | Text lines (variant text); the last line is shorter |
rows | number | 3 | Table rows (variant row) |
width | CSSProperties['width'] | '100%' | CSS width of text lines |
label | string | "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>
| Kind | Name | Description |
|---|---|---|
| attribute | variant | 'text' | 'row' | 'card' | 'avatar'; default 'text' |
| attribute | lines | Text lines (variant text); the last line is shorter; default 1 |
| attribute | rows | Table rows (variant row); default 3 |
| property / JSON attribute | width | CSS width of text lines; default '100%' |
| attribute | label | Accessible name (aria-label); default "Loading" ("Loading rows" for variant row) |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-change | (React: onChange) |
| event | co-input | (React: onInput) |