Skip to main content

Skeleton

A placeholder to show while content is loading.

Basic usage​

Basic usage
import { LhSkeleton } from '@lh-ui/react'

export default function Demo() {
return <LhSkeleton avatar rows={2} sx={{ w: 300 }} />
}

Skeleton Props​

PropDescriptionTypeOptionsDefault
loadingWhether to show the skeleton (renders children when false)boolean—true
rowsNumber of text rowsnumber—3
avatarWhether to include a circular avatar placeholderboolean—false
animatedWhether to enable the animationboolean—true
sxShorthand layout propsSxProps——

SkeletonItem Props​

LhSkeletonItem is an independently exported placeholder block that can be used standalone to compose arbitrary skeleton structures.

PropDescriptionTypeOptionsDefault
variantPlaceholder shape'text' | 'rect' | 'circle'—'text'
animatedWhether to enable the animationboolean—true
classNameAppended class namestring——
styleAppended inline styleCSSProperties——
sxShorthand layout propsSxProps——
import { LhSkeletonItem } from '@lh-ui/react'

export default function Demo() {
return (
<div style={{ display: 'flex', gap: 16, width: 300 }}>
<LhSkeletonItem variant="circle" />
<div style={{ flex: 1 }}>
<LhSkeletonItem style={{ marginBottom: 8 }} />
<LhSkeletonItem style={{ width: '60%' }} />
</div>
</div>
)
}
Row width algorithm

When rows > 1, the last row shrinks to 60% to mimic real paragraph layout; the root element must have a determined width (row widths are percentages).

Accessibility

The skeleton container emits aria-busy="true" + aria-live="polite"; all placeholder blocks are aria-hidden, and once data is ready the screen reader announces the real content again. Under prefers-reduced-motion, the animation automatically degrades to a static placeholder.

Styles​

import '@lh-ui/react/style/skeleton'