Skeleton
A loading placeholder that mimics content shape while data is fetching.
Import
import { Skeleton } from '@matix/components/skeleton';Usage
Shapes
Match the skeleton shape to the content it replaces.
{/* Text lines */}
<Skeleton width="100%" height={16} />
<Skeleton width="80%" height={16} />
<Skeleton width="60%" height={16} />
{/* Avatar */}
<Skeleton variant="circular" width={40} height={40} />
{/* Card */}
<Skeleton variant="rounded" width="100%" height={120} />Card Loading State
import * as stylex from '@stylexjs/stylex';
const layout = stylex.create({
row: { display: 'flex', gap: 12, alignItems: 'flex-start' },
avatar: { flexShrink: 0 },
lines: { flex: 1, display: 'flex', flexDirection: 'column', gap: 8 },
});
<div {...stylex.props(layout.row)}>
<Skeleton variant="circular" width={40} height={40} sx={layout.avatar} />
<div {...stylex.props(layout.lines)}>
<Skeleton width="60%" height={14} />
<Skeleton width="90%" height={14} />
<Skeleton width="75%" height={14} />
</div>
</div>;Custom Styles
import * as stylex from '@stylexjs/stylex';
const custom = stylex.create({
image: { width: 200, height: 200, borderRadius: 8 },
});
<Skeleton sx={custom.image} />;API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'text' | 'circular' | 'rectangular' | 'rounded' | 'text' | Shape variant |
width | string | number | — | Explicit width |
height | string | number | — | Explicit height |
sx | StyleXStyles | — | StyleX style override |
All other HTML attributes, such as id and aria-*, go to the root element.
Accessibility
- Renders a
<span>witharia-hidden="true"— screen readers skip it. - The pulse animation respects
prefers-reduced-motion: when the user has reduced motion enabled, the animation is disabled via CSS and the skeleton is shown as a static element. - To communicate a loading state to screen readers, place an
aria-live="polite"region outside the skeleton that updates when content loads.
This is an RSC-safe component — it ships no JavaScript to the browser.