Skeleton
Placeholder shapes that mirror the layout of content while it loads, so the page does not jump when the data arrives. Three shapes (text line, circle, rectangle); size anything with className.
Installation
Add Skeleton to your project with the CK-UI CLI. It copies the source into your project, so the code is yours to change.
- Adds
Skeleton.tsxto your CK-UI folder (src/components/ck-ui by default)- Installs
- No extra npm packages
First time with CK-UI in this project? Run npx ck-ui-cli@latest init once before adding components. The installation guide explains what it sets up.
Manual installationInstall the packages and copy the files yourself.
Create or update your Skeleton component
Copy this code to create your Skeleton component
Test Your Component
- 1. Add the component to a test page
- 2. Check all props and variants work as expected
- 3. Verify responsive behavior
- 4. Test with different content/data
- 5. Ensure accessibility features work correctly
Profile
A circle for the avatar and two text lines.
Card
A rectangle for media, then a heading line and Skeleton.Text for the body.
List
Repeat a row skeleton for tables and lists.
Paragraph
Skeleton.Text renders several lines with a shorter last line. Toggle to swap it for the real content.
Accessibility
- Skeletons are decorative and carry aria-hidden="true"; screen readers skip them.
- Announce the loading state on the container instead:
aria-busy="true"while loading plus a visually hidden "Loading…" text, as in the examples. - The pulse animation stops when the user prefers reduced motion.
- The fill is
foreground/10, so the shapes stay visible on background, surface and muted areas in light and dark mode.
API Reference
Server-compatible. Import with import * as Skeleton from "@/components/ui/Skeleton".
Skeleton.Root
| Prop | Type | Default | Description |
|---|---|---|---|
shape | "text""circle""rect" | "text" | Default size and rounding: text h-4 full width, circle 40px, rect h-32 full width. |
className | "string" | "undefined" | Size or round it differently, e.g. h-6 w-24. Merged last. |
Skeleton.Text
Several text lines; the last one is shorter.
| Prop | Type | Default | Description |
|---|---|---|---|
lines | "number" | "3" | Number of lines. |
lineClassName | "string" | "undefined" | Classes for every line. |
className | "string" | "undefined" | Classes for the wrapper. |