Skeleton
Animated placeholder for loading states. Renders as a rectangle, circle, or multi-line text block with a pulse animation.
import { Skeleton } from "phoundry-ui";Rectangle
Loading interactive example…
View source
<script lang="ts"> import { Skeleton } from "phoundry-ui";</script>
<div class="max-w-sm space-y-3"> <Skeleton width="200px" height="40px" /> <Skeleton width="100%" height="20px" /></div>Circle
Loading interactive example…
View source
<script lang="ts"> import { Skeleton } from "phoundry-ui";</script>
<div class="flex items-center gap-3"> <Skeleton variant="circle" width="48px" /> <Skeleton variant="circle" width="32px" /></div>Text Lines
Loading interactive example…
View source
<script lang="ts"> import { Skeleton } from "phoundry-ui";</script>
<div class="max-w-sm space-y-4"> <Skeleton variant="text" lines={3} /> <Skeleton variant="text" lines={5} width="300px" /> <div> <p class="mb-1 text-[10px] text-txt-tertiary">Single line title shimmer</p> <Skeleton variant="text" lines={1} width="120px" /> </div></div>Card Composition
Loading interactive example…
View source
<script lang="ts"> import { Skeleton } from "phoundry-ui";</script>
<div class="max-w-sm"> <div class="flex gap-3 rounded-lg border border-border-muted p-4"> <Skeleton variant="circle" width="40px" /> <div class="flex-1 space-y-2"> <Skeleton width="60%" height="14px" /> <Skeleton variant="text" lines={2} /> </div> </div></div>API
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
variant | "text" | "rect" | "circle" | 'rect' | Shape of the placeholder. |
width | string | — | CSS width value. Defaults to 100% for rect/text, 40px for circle. |
height | string | — | CSS height value. Defaults to 20px for rect, matches width for circle. |
lines | number | 3 | Number of text lines (only for variant="text"). |
class | ClassValue | — | Additional CSS classes. |
style | string | — | Inline styles on the stable component root. |
Usage tips
- Compose multiple skeletons to mirror the layout of the content being loaded.
- The last line in
variant="text"is automatically shorter (75%) for a natural look. - Use fixed
width/heightto prevent layout shift when content loads. - Add utility classes via
class(e.g. rounded corners) to mirror cards or avatar stacks. - Animation follows global motion preferences via the theme stylesheet - no extra props required.
Styling
.ph-skeleton is the stable root hook. Consumer class values are additive, and style applies to that root. Styling uses vanilla CSS with semantic state attributes. The root emits data-variant. width and height remain CSS-length props; defaults retain the 2.5rem circle, 1.25rem rectangle height, and 0.75rem text-line height. Text mode still ignores height and shortens the last line to 75%. Pulse animation uses --ph-motion-pulse (2000ms), and stops under reduced-motion preferences. Internal part selectors and --_ph-* properties remain implementation details.