Loading component…
Loading component…
Gray shapes in the exact size of the content they stand in for
To reuse this local React demo, copy all files from the Code tab into the same folder, then import Skeleton from ./skeleton.
import { Loading, Skeleton } from "@/components/ui/skeleton";
export function RunList({ runs }: { runs?: Run[] }) {
// Loading gets the list's own class, so its rows sit in the same layout
if (!runs)
return (
<Loading label="Loading runs" className="run-list">
{[212, 164, 176].map((w, i) => (
<div key={i} className="run-row">
<Skeleton width={16} height={16} radius={4} />
{/* line: as tall as the 20px text line, the 10px bar centered in it */}
<span className="run-row__title">
<Skeleton line width={w} height={10} />
</span>
</div>
))}
</Loading>
);
return (
<div className="run-list">
{runs.map((r) => (
<div key={r.id} className="run-row">
<AgentMark id={r.agent} />
<span className="run-row__title">{r.title}</span>
</div>
))}
</div>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| Skeleton · width | number \| string | "100%" | px or any CSS length; never wider than its parent |
| Skeleton · height | number \| string | 12 | The shape's own height |
| Skeleton · radius | number \| string | 6px (--aui-radius-sm) | Corner radius – "50%" for an avatar |
| Skeleton · line | boolean \| number \| string | Puts the shape in a box as tall as the text line it replaces (true = 1lh, or a length) and centers it there – the row keeps its height when the words land | |
| Skeleton · ...span props | ComponentProps<"span"> | className, style, ref – with line they go to the line box | |
| Loading · label | string | "Loading" | What loads, for screen readers – "Loading runs" |
| Loading · className | string | The real layout's class, so the grid or list is the same one the data fills | |
| Loading · ...div props | ComponentProps<"div"> | style, ref, data-* – everything goes to the wrapper |
Never wider than its parent (max-width: 100%), so fixed widths hold on phones
Give the Loading wrapper the real layout's class – the narrow layout of the data applies to the skeletons too
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.