UI

Skeleton

A placeholder shaped like the content that is still loading.

import { Skeleton } from '@uthereal/ui/skeleton'

Skeleton playground

Loading interactive preview…

Overview

Arc's skeleton: a placeholder that reserves the space of loading content, so the layout does not jump when it arrives. By default it draws Arc's three text lines (a heading bar, a body line and a shorter last line); it also draws a block for images, charts and cards, a circle, or an avatar beside the lines. The root is a busy role="status" region named by label; the shapes are hidden from assistive technology. Given children, it crossfades into them once loading is false.

Use a skeleton when you know the shape of what is coming. When the amount done is known, use a progress bar.

Usage

import { Skeleton } from '@uthereal/ui/skeleton'

export function Summary({ text }: { text?: string }) {
  return (
    <Skeleton label="Loading summary" loading={text === undefined}>
      <p>{text}</p>
    </Skeleton>
  )
}

With children, the skeleton shows while loading is true; when it turns false the placeholder fades out, the content rises in 4 pixels, and the height springs between the two. Without children, render the skeleton in place of the content yourself. Text lines fill the container unless you set widthPx.

Examples

Shapes

text draws lines bars (3 by default) on Arc's 12 pixel rhythm: a 48% heading bar 16 pixels tall, 12 pixel body lines, and a 72% last line. avatar adds a 44 pixel circle beside them. rect takes a height (96 pixels by default) and circle a diameter in height (40 pixels by default).

Motion

subtle pulses as in Arc, each block a beat (90 milliseconds) after the one above, dimming to .52. expressive sweeps a light shimmer across the fill. none stays static.

Composed placeholders

avatar puts a circle beside the lines in one row, as in Arc. For other layouts, combine shapes yourself and give one of them the label for the whole region.

<Skeleton avatar lines={2} label="Loading comment" />

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
shapetext | rect | circleDefault: "text"text draws lines at the text rhythm, rect a block such as an image or card, circle an avatar.
linesintegerDefault: 3Number of text lines, 1 to 6 (3 by default, as in Arc): a 48% heading bar, 12px body lines and a 72% last line. Text only.
avatarbooleanDefault: falseText only: a round avatar placeholder (44 px) beside the lines, in one row, pulsing first.
widthPxinteger—Width in pixels. Omit it to fill the container. Circles use height.
heightinteger—Height of a rect or diameter of a circle, in pixels. Omit it for 96 (rect) or 40 (circle). Text lines follow the font size.
labelstringDefault: "Loading content"Accessible name of the busy status region, never shown, e.g. "Loading messages".
loadingbooleanDefault: trueUsed with React children: while true the placeholder shows; when false it crossfades into the children and the height springs between the two.
recipestudio | softDefault: "studio"Visual treatment: corner radii and fill follow the recipe.
themeSkeletonTheme—Color mode and tokens (surface, borderStrong, radius, default rect, circle and avatar sizes). See Theming.
motionnone | subtle | expressiveDefault: "subtle"subtle pulses, expressive sweeps a light shimmer, none is static. Both loops stop after about 20 seconds, and system reduced motion keeps the placeholder static.
dirltr | rtl—Reading direction; reverses avatar placement and shimmer direction in RTL. Omit it to inherit the page direction.

React integration

PropPurpose
presetApplication defaults, overridden by explicit instance arguments
tokensCSS variables applied after the typed theme
childrenContent to reveal once loading is false (crossfade and height spring)
refThe root <div role="status">, or the frame around children
className, styleAdded to the root element
Native attributesid, aria-*, data-* and the rest, forwarded to the root

Keyboard & accessibility

A skeleton is not focusable. As in Arc, its root is a role="status" region named by label with aria-busy="true"; the shapes are aria-hidden. With children, the frame around them is aria-busy while loading. Name what is loading ("Loading messages"). When several skeletons form one placeholder, mark the region that will receive the content with aria-busy while it loads. Under forced colors each shape gets an outline.

Motion and theming

The pulse and the shimmer each run 11 cycles of 1.8 seconds, about 20 seconds, and then rest, so a stalled request does not animate forever. With children, the placeholder fades out over 160 milliseconds, the content rises in on Arc's enter curve, and the height springs on the smooth spring. motion="none" and system reduced-motion preferences keep the placeholder static and make the swap a short fade (none: immediate). Skeletons have no motion options.

theme takes a mode and the surface, borderStrong and radius tokens, plus height, circleSize and avatarSize for the default rect height, circle diameter and avatar size. As in Arc, the fill is borderStrong at 38% over the surface and bars use the control radius. An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, Skeleton is a leaf with no actions. Arrange several shapes inside a Stack. See Building with agents.

{
  "type": "Skeleton",
  "props": { "shape": "text", "lines": 3, "label": "Loading summary" },
  "children": []
}

On this page