Skip to content
TopClass UI

Skeleton

A placeholder that holds the shape of content while it loads: lines of text, a circle, a rectangle or a card.

server - 0 KB

Skeleton

server - 0 KB

A placeholder that holds the shape of content while it loads: lines of text, a circle, a rectangle or a card.

Install

Try it

variant
rows

The code

skeleton.tsx
import { Skeleton } from 'topclassui/skeleton'

<div className="max-w-sm">
  <Skeleton />
</div>

Give the skeleton the real dimensions through className; rows is clamped from 1 to 50, and a wrong size is a layout shift.

Every state

1 state
Text
Circle
Rect
Card

Import from the package

topclassui/skeleton
import { Skeleton } from 'topclassui/skeleton'

Install once:npm i topclassui@beta zod

Examples

  • Most often it is a <Suspense> fallback. Pick the shape of what is coming with variant: text, circle, rect or card.
  • The text shape is as tall as the lines it replaces at any type step, so set the type step on it as you would on the text.
  • With more than one row, the last row is two thirds wide, as a paragraph ends.
  • The pulse stops under reduced motion.
  • Badge, Avatar, Button, Card, Input, Table and Textarea also ship a skeleton of their own exact size.
media-object
variants
rows
beside-text

Invoice 2041 was paidon the seventh of Octoberby bank transfer.

Invoice 2041 was paidon the seventh of Octoberby bank transfer.

custom-size
In Arabic, right to left

Props

The props of Skeleton
PropTypeDefaultLimitsDescription
rowsinteger, min 1, max 503min 1, max 50How many lines the text shape holds, clamped to the bounds; the other shapes ignore it.
varianttext | circle | rect | card"text"-The shape it holds the place of: lines of text, a circle, a rectangle or a card.

Keyboard and accessibility

Nothing to operate: it is not interactive on its own.

  • Every shape renders aria-hidden, so a screen reader never reads a list of empty boxes.
  • Mark the loading region itself, for example with aria-busy="true" on the element the content will fill.

Right to left

Rows start at the inline start, so the short last row and a circle beside the text sit on the right in Arabic.

Server and client

Renders on the server and ships no JavaScript.

Files: index.tsx.

On the chip: server - 0 KB.