Skip to content
All components
Primitives

Skeleton

Reserve the shape of content that is loading so the layout stays stable and people can anticipate what will appear.

A loading placeholder that holds the layout still.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add skeleton

Then import it from @/components/ui/skeleton. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Profile row

Placeholder for an avatar with two lines of text. Shapes mirror the content that will replace them.

"use client"

import { Skeleton } from "@/components/ui/skeleton"

export function SkeletonProfileRow() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <div className="flex w-full items-center gap-4">
        <Skeleton className="size-12 rounded-full" />
        <div className="flex flex-1 flex-col gap-2">
          <Skeleton className="h-4 w-full" />
          <Skeleton className="h-4 w-2/3" />
        </div>
      </div>
    </div>
  )
}

Card

Placeholder for a media card with a title and summary. The media area reserves its final ratio so the layout does not shift.

"use client"

import { Skeleton } from "@/components/ui/skeleton"

export function SkeletonCard() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <div className="flex w-full flex-col gap-3 rounded-16 border border-soft-200 p-3">
        <Skeleton className="aspect-video w-full rounded-12" />
        <Skeleton className="h-5 w-3/4" />
        <Skeleton className="h-4 w-full" />
        <Skeleton className="h-4 w-1/2" />
      </div>
    </div>
  )
}

Loading list

Loading list region with aria-busy and visually hidden loading text. Skeleton itself is passive; the consumer supplies the loading status.

"use client"

import { Skeleton } from "@/components/ui/skeleton"

export function SkeletonLoadingList() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <section aria-label="Invoices" aria-busy="true" className="flex w-full flex-col gap-3">
        <p className="sr-only">Loading invoices</p>
        {["first", "second", "third"].map((row) => (
          <div key={row} className="flex items-center justify-between gap-4">
            <div className="flex flex-1 flex-col gap-2">
              <Skeleton className="h-4 w-1/2" />
              <Skeleton className="h-3 w-1/3" />
            </div>
            <Skeleton className="h-6 w-16 rounded-full" />
          </div>
        ))}
      </section>
    </div>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

Skeleton

Reserve representative content space during loading.

Skeleton props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
Skeleton inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

Accessibility & usage

From registry/ui/skeleton.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • Initial loads of lists, cards, tables and profiles whose layout is known in advance.
  • Content areas that load in under a few seconds, where a full-page spinner would feel slower and cause layout shift.
  • Lazy sections below the fold that load independently of the rest of the page.

When not to use

  • When loading has finished and there is no content; that is an empty state.
  • For operations with measurable progress such as uploads or exports.
  • For short actions triggered by a button, where the button's own loading state is enough.
  • When the final layout is unknown; a mismatched skeleton causes the shift it is meant to prevent.

Anatomy

Skeleton
A div with a muted fill, rounded corners and a pulse animation. Has no size of its own: the consumer sets width, height and shape with classes.

Keyboard & interaction

  • Passive and never focusable; it does not load data or announce anything.
  • Mark the loading region with aria-busy="true" and provide loading text (visible or visually hidden), then remove both when content arrives.
  • The pulse animation stops when the user prefers reduced motion (motion-reduce:animate-none is built in).
  • Move focus only if the user triggered the load and expects to continue in the new content; otherwise leave focus where it is.

Responsive behavior

  • Size skeletons with the same responsive classes as the content they stand for (widths in percent or fr, aspect ratios for media), so they reflow identically.
  • Use fewer placeholder rows on small screens; enough to fill the first viewport is enough.
  • Reserve media areas with an aspect ratio rather than a fixed height so the placeholder matches at every width.

Content guidelines

  • Loading text names what is loading: 'Loading invoices', not 'Please wait'.
  • Vary line widths (full, two-thirds, half) so placeholders read as text rather than a grid of bars.
  • If loading fails, replace the skeleton with an error message that says what failed and offers a retry.

Alternatives

  • Spinner — Short indeterminate work where the shape of the result is unknown.
  • Progress — Work with measurable completion.
  • Empty — Loading finished and there is nothing to show.

Resources