Skeleton to content
Loading placeholders shaped exactly like the real feed, with a soft shimmer, that cross-fade into the content piece by piece when it arrives.
"use client";
import { useEffect, useState, type CSSProperties } from "react";
import "./skeleton-feed.css";
const POSTS = [
{
name: "Rosa Lindgren",
handle: "Design lead",
time: "2h",
text: "Shipped the new onboarding today. Five screens became two, and completion went from 61% to 84%.",
tone: "#ff5a1f",
likes: 128,
},
{
name: "Theo Barros",
handle: "Engineer",
time: "5h",
text: "Reminder that a loading skeleton should look like the thing that's loading. Not a generic gray block.",
tone: "#2b35ff",
likes: 342,
},
{
name: "Ines Kaur",
handle: "Researcher",
time: "1d",
text: "Ten interviews in, the clearest pattern: people trust products that show their work.",
tone: "#0e0e10",
likes: 87,
},
];
/**
* SkeletonFeed
* - The skeleton and the real card share one layout, so nothing jumps when data arrives.
* - aria-busy on the list tells assistive tech the content is loading.
*/
export function SkeletonFeed({
theme = "light",
}: {
theme?: "light" | "dark";
}) {
const [loading, setLoading] = useState(true);
const [round, setRound] = useState(0);
useEffect(() => {
const t = setTimeout(() => setLoading(false), 2200); // replace with your fetch
return () => clearTimeout(t);
}, [round]);
return (
<div className="gu-skel" data-theme={theme}>
<div className="gu-skel__head">
<b>Team feed</b>
<button
type="button"
onClick={() => {
setLoading(true);
setRound((r) => r + 1);
}}
disabled={loading}
>
{loading ? "Loading…" : "Reload"}
</button>
</div>
<ul aria-busy={loading} aria-label="Team feed">
{POSTS.map((p, i) => (
<li
key={p.name}
className="gu-skel__card"
data-loading={loading ? "" : undefined}
style={{ "--i": i } as CSSProperties}
>
<span
className="gu-skel__avatar"
style={{ "--tone": p.tone } as CSSProperties}
>
<span className="gu-skel__real">
{p.name
.split(" ")
.map((w) => w[0])
.join("")}
</span>
</span>
<div className="gu-skel__body">
<p className="gu-skel__line gu-skel__line--name">
<span className="gu-skel__real">
<b>{p.name}</b> · {p.handle} · {p.time}
</span>
</p>
<p className="gu-skel__line gu-skel__line--text">
<span className="gu-skel__real">{p.text}</span>
</p>
<p className="gu-skel__line gu-skel__line--meta">
<span className="gu-skel__real">♥ {p.likes} · Reply</span>
</p>
</div>
</li>
))}
</ul>
<p className="gu-sr" role="status">
{loading ? "Loading posts" : "3 posts loaded"}
</p>
</div>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Skeleton to content
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A social/team feed that shows skeleton placeholders shaped exactly like its real cards (avatar circle, name line, text block, meta line), with a soft shimmer, then cross-fades into the real content card by card and line by line.
## Layout and look
- Header: "Team feed" (21px, weight 900) and an outline pill "Reload" button.
- Cards: radius 20px, padding 16px, hairline border; 44px avatar circle (initials on a brand color) + body with name/role/time (muted), post text, and "♥ 128 · Reply".
- Skeleton: the real text is present but invisible; each line gets a rounded 8%-Ink bone over it (name 55% wide, meta 30%), and the avatar is a bone circle. A diagonal light band sweeps across each card every 1.4s (staggered per card).
## Behavior and motion
1. Loading: data-loading on each card. Done: bones disappear and the real text fades in with delay = card × 120ms + line × 80ms (500ms cubic-bezier(0.16, 1, 0.3, 1)).
2. Because skeleton and content share one layout, there is zero layout shift.
## Accessibility
- The list has aria-busy while loading; a status line says "Loading posts" / "3 posts loaded".
- prefers-reduced-motion: no shimmer, a gentle opacity pulse instead, no stagger.
## Props
theme. Replace the timeout with your fetch and POSTS with data.
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### SkeletonFeed.tsx
```tsx
"use client";
import { useEffect, useState, type CSSProperties } from "react";
import "./skeleton-feed.css";
const POSTS = [
{
name: "Rosa Lindgren",
handle: "Design lead",
time: "2h",
text: "Shipped the new onboarding today. Five screens became two, and completion went from 61% to 84%.",
tone: "#ff5a1f",
likes: 128,
},
{
name: "Theo Barros",
handle: "Engineer",
time: "5h",
text: "Reminder that a loading skeleton should look like the thing that's loading. Not a generic gray block.",
tone: "#2b35ff",
likes: 342,
},
{
name: "Ines Kaur",
handle: "Researcher",
time: "1d",
text: "Ten interviews in, the clearest pattern: people trust products that show their work.",
tone: "#0e0e10",
likes: 87,
},
];
/**
* SkeletonFeed
* - The skeleton and the real card share one layout, so nothing jumps when data arrives.
* - aria-busy on the list tells assistive tech the content is loading.
*/
export function SkeletonFeed({
theme = "light",
}: {
theme?: "light" | "dark";
}) {
const [loading, setLoading] = useState(true);
const [round, setRound] = useState(0);
useEffect(() => {
const t = setTimeout(() => setLoading(false), 2200); // replace with your fetch
return () => clearTimeout(t);
}, [round]);
return (
<div className="gu-skel" data-theme={theme}>
<div className="gu-skel__head">
<b>Team feed</b>
<button
type="button"
onClick={() => {
setLoading(true);
setRound((r) => r + 1);
}}
disabled={loading}
>
{loading ? "Loading…" : "Reload"}
</button>
</div>
<ul aria-busy={loading} aria-label="Team feed">
{POSTS.map((p, i) => (
<li
key={p.name}
className="gu-skel__card"
data-loading={loading ? "" : undefined}
style={{ "--i": i } as CSSProperties}
>
<span
className="gu-skel__avatar"
style={{ "--tone": p.tone } as CSSProperties}
>
<span className="gu-skel__real">
{p.name
.split(" ")
.map((w) => w[0])
.join("")}
</span>
</span>
<div className="gu-skel__body">
<p className="gu-skel__line gu-skel__line--name">
<span className="gu-skel__real">
<b>{p.name}</b> · {p.handle} · {p.time}
</span>
</p>
<p className="gu-skel__line gu-skel__line--text">
<span className="gu-skel__real">{p.text}</span>
</p>
<p className="gu-skel__line gu-skel__line--meta">
<span className="gu-skel__real">♥ {p.likes} · Reply</span>
</p>
</div>
</li>
))}
</ul>
<p className="gu-sr" role="status">
{loading ? "Loading posts" : "3 posts loaded"}
</p>
</div>
);
}
```
### skeleton-feed.css
```css
/* SkeletonFeed: change these colors to match your brand. */
.gu-skel {
--card: #fbf8f2;
--text: #0e0e10;
--muted: #57534b;
--line: rgb(14 14 16 / 0.1);
--bone: rgb(14 14 16 / 0.08);
--shine: rgb(255 255 255 / 0.7);
--focus: #2b35ff;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
width: min(100%, 460px);
color: var(--text);
font-family: system-ui, sans-serif;
}
.gu-skel[data-theme="dark"] {
--card: #18181b;
--text: #f3eee3;
--muted: #aea89c;
--line: rgb(243 238 227 / 0.1);
--bone: rgb(243 238 227 / 0.08);
--shine: rgb(243 238 227 / 0.12);
--focus: #d7ff3a;
}
.gu-skel__head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.gu-skel__head b {
font-size: 1.3rem;
font-weight: 900;
letter-spacing: -0.02em;
}
.gu-skel__head button {
min-height: 44px;
padding: 0 18px;
border: 1.5px solid var(--line);
border-radius: 999px;
background: none;
color: inherit;
font: inherit;
font-weight: 700;
cursor: pointer;
}
.gu-skel__head button:disabled {
opacity: 0.5;
cursor: progress;
}
.gu-skel__head button:focus-visible {
outline: 3px solid var(--focus);
}
.gu-skel ul {
display: grid;
gap: 10px;
margin: 0;
padding: 0;
list-style: none;
}
.gu-skel__card {
display: grid;
grid-template-columns: 44px 1fr;
gap: 14px;
padding: 16px;
border: 1px solid var(--line);
border-radius: 20px;
background: var(--card);
}
.gu-skel__avatar {
position: relative;
display: grid;
place-items: center;
width: 44px;
height: 44px;
border-radius: 50%;
background: var(--tone);
color: #f3eee3;
font-size: 0.8rem;
font-weight: 900;
}
.gu-skel__body {
display: grid;
gap: 8px;
}
.gu-skel__line {
position: relative;
margin: 0;
font-size: 0.92rem;
line-height: 1.45;
}
.gu-skel__line--name {
color: var(--muted);
font-size: 0.85rem;
}
.gu-skel__line--name b {
color: var(--text);
}
.gu-skel__line--meta {
color: var(--muted);
font-size: 0.82rem;
font-weight: 600;
}
/* Real content fades in with a stagger per card and per line */
.gu-skel__real {
transition: opacity 0.5s calc(var(--i) * 120ms + var(--l, 0ms)) var(--ease);
}
.gu-skel__line--text {
--l: 80ms;
}
.gu-skel__line--meta {
--l: 160ms;
}
/* Loading: hide content, show bones of the same size on top */
.gu-skel__card[data-loading] .gu-skel__real {
opacity: 0;
transition: none;
}
.gu-skel__card[data-loading] .gu-skel__avatar {
background: var(--bone);
}
.gu-skel__card[data-loading] .gu-skel__line::before {
content: "";
position: absolute;
inset: 3px 0;
border-radius: 6px;
background: var(--bone);
}
.gu-skel__card[data-loading] .gu-skel__line--name::before {
right: 45%;
}
.gu-skel__card[data-loading] .gu-skel__line--meta::before {
right: 70%;
}
/* Shimmer: one bright band sweeping across the whole card */
.gu-skel__card[data-loading] {
position: relative;
overflow: hidden;
}
.gu-skel__card[data-loading]::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(
100deg,
transparent 30%,
var(--shine) 50%,
transparent 70%
);
transform: translateX(-100%);
animation: gu-skel-shine 1.4s calc(var(--i) * 120ms) infinite;
}
@keyframes gu-skel-shine {
to {
transform: translateX(100%);
}
}
.gu-skel__card:not([data-loading]) .gu-skel__avatar {
transition: background-color 0.4s calc(var(--i) * 120ms);
}
.gu-sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
@media (prefers-reduced-motion: reduce) {
.gu-skel__card[data-loading]::after {
animation: none;
display: none;
}
.gu-skel__card[data-loading] .gu-skel__line::before {
animation: gu-skel-pulse 1.6s ease-in-out infinite;
}
@keyframes gu-skel-pulse {
50% {
opacity: 0.5;
}
}
.gu-skel__real {
transition-delay: 0s;
transition-duration: 0.2s;
}
}
```
You might also want
Next piece: Smart tooltips3D tilt card
Components, intermediate
Depth cards hero
Components, intermediate
Empty states set
Components, beginner