SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Skeleton

Loading placeholders.

View code
tsx
<Card aria-busy="true" aria-label="Loading comments">
	<Card.Content>
		<div mix={[hstack({ gap: 3, align: "center" })]}>
			<Skeleton mix={[pulse(), css({ inlineSize: "2.5rem", blockSize: "2.5rem", borderRadius: "9999px", flexShrink: "0" })]} />
			<div mix={[vstack({ gap: 2, align: "stretch" }), css({ flexGrow: "1" })]}>
				<Skeleton mix={[pulse(), css({ inlineSize: "9rem" })]} />
				<Skeleton mix={[pulse(), css({ inlineSize: "5rem", blockSize: "0.75rem" })]} />
			</div>
		</div>

		<div mix={[vstack({ gap: 2, align: "stretch" })]}>
			<Skeleton mix={[pulse()]} />
			<Skeleton mix={[pulse()]} />
			<Skeleton mix={[pulse(), css({ inlineSize: "60%" })]} />
		</div>

		<div mix={[hstack({ gap: 2, align: "center" })]}>
			<Skeleton mix={[pulse(), css({ inlineSize: "4.5rem", blockSize: "2rem", borderRadius: "9999px" })]} />
			<Skeleton mix={[pulse(), css({ inlineSize: "4.5rem", blockSize: "2rem", borderRadius: "9999px" })]} />
		</div>
	</Card.Content>
</Card>

Demo apps

Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.

Every demo, landings and docs sites alike, is listed in the showcase.

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { Skeleton } from "@sdxc/ui/app";

A static loading placeholder: a rounded block filled with the neutral border color, sized to its container and one text line tall by default. Compose pulse() or shimmer() through mix for a motion cue.

Composition

The parts the component publishes, each a static property of the host.

  • Skeleton
  • Skeleton.RowA placeholder table row built from the real Table.Row and Table.Cell, so it takes --ui-table-row-block-size and the table's cell padding and rules; place it in a real table body.
  • Skeleton.TableA placeholder table body of rows Skeleton.Rows, for under the real table header while the first page loads, so the header, columns and height hold still when the data arrives.
  • Skeleton.StatA placeholder stat card drawn inside the real StatCard frame, with bars on the label and value lines and the delta placed as a real one is in every group layout, so it is as tall as the card it precedes; delta and chart add parts.
  • Skeleton.ListA placeholder list of rows rows at --ui-skeleton-list-row-block-size (3.5rem, a two-line row), each an optional avatar and one or two text bars; set the variable to the real list's row height.
  • Skeleton.TextLays out real content unseen and paints a bar over each line it wraps to, so a placeholder takes exactly the content's size at every width: a name that wraps on a phone wraps in its placeholder too.

Examples

Table body

MonitorStatusUptimeLast check
View code
tsx
<Table>
	<Table.Header>
		<Table.Row>
			<Table.Column>Monitor</Table.Column>
			<Table.Column>Status</Table.Column>
			<Table.Column>Uptime</Table.Column>
			<Table.Column>Last check</Table.Column>
		</Table.Row>
	</Table.Header>
	<Skeleton.Table rows={5} columns={4} label="Loading monitors" />
</Table>

Stat cards

View code
tsx
<div role="status" aria-busy="true" aria-label="Loading stats" mix={[hstack({ gap: 3, align: "start" })]}>
	<Skeleton.Stat delta />
	<Skeleton.Stat delta chart />
</div>

List

View code
tsx
<Skeleton.List rows={4} avatar label="Loading conversations" />

Text

View code
tsx
<div aria-busy="true">
	<strong><Skeleton.Text>{person.name}</Skeleton.Text></strong>
	<p><Skeleton.Text>{person.bio}</Skeleton.Text></p>
	<Skeleton.Text block><Button size="sm">Follow</Button></Skeleton.Text>
</div>

Announced to screen readers

View code
tsx
<div mix={[is("16rem")]}>
	<Skeleton role="status" aria-hidden="false" aria-label="Loading Ana's profile" />
</div>

Round avatar

View code
tsx
<Skeleton style={{ blockSize: "2.5rem", inlineSize: "2.5rem", borderRadius: "9999px" }} />

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

Also accepts everything in TagProps<"div">.

Skeleton.Row

PropTypeDefaultRequiredDescription
columnsnumber—NoCells in the row; match the real table's columns. Default: 4.

Also accepts everything in TagProps<"tr">.

Skeleton.Table

PropTypeDefaultRequiredDescription
rowsnumber—NoPlaceholder rows. Default: 5.
columnsnumber—NoCells per row; match the real table's columns. Default: 4.

Also accepts everything in TagProps<"tbody">.

Also accepts everything in Labelled.

Skeleton.Stat

PropTypeDefaultRequiredDescription
deltaboolean—NoDraws the delta pill where a card with a delta sets it.
chartboolean—NoDraws the chart band under the value, as a card with a sparkline has.

Also accepts everything in Omit<TagProps<"div">, "children">.

Also accepts everything in Labelled.

Skeleton.List

PropTypeDefaultRequiredDescription
rowsnumber—NoPlaceholder rows. Default: 5.
avatarboolean—NoLeads each row with a round avatar placeholder.
lines1 | 2—NoText lines per row. Default: 2.

Also accepts everything in TagProps<"div">.

Also accepts everything in Labelled.

Skeleton.Text

PropTypeDefaultRequiredDescription
blockboolean—NoDraws one bar over the whole box instead of one per wrapped line, for an inline-flex box such as a badge or a button. @default false

Also accepts everything in TagProps<"span">.

@sdxc/ui

Can’t find it? Contact us