Skip to Content
NarakUI

Skeleton

A loading placeholder component that mimics the structure of content while it loads.

Basic

A skeleton is a block: it fills its container's width and is 24px tall. Set width and height, or size it with classes. For a line of text, use SkeletonText.

Default

Custom height

Text lines

SkeletonText stands in for one line of text. It takes the font size and line height of the text around it. Set width to about the length of the text it replaces. For a paragraph, use one SkeletonText for each line and vary the widths.

List row

Match the shape of the row that will load: an avatar, two lines of text, and an action. When the parent does not set the typography of a line, set variant to the typography class of the text it replaces.

Metric cards

Keep the final layout in place while the data loads. The metric names are known, so they show as text; only the values are placeholders. SkeletonGroup tells screen readers that the content is loading.

Loading metrics

Visibility

Share of voice

Position

Animation

Skeletons pulse by default and stop automatically when prefers-reduced-motion is enabled. Set animate={false} for a static placeholder.

Animated (default)

Static

Guidelines

Do:

  • Show the structure of the content that loads: its blocks, rows, and lines. The placeholder does not have to match the final layout exactly.
  • Vary the widths of text lines so that they look like text.
  • Make a paragraph or a card from several skeletons.
  • Show headings, labels, and other text that you know before the data loads as text.
  • Put the skeletons in a SkeletonGroup with a label, so that screen readers announce that the content is loading.

Don't:

  • Change the size of a skeleton while it loads.

Installation

pnpm dlx shadcn@latest add @narakui/skeleton

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/skeleton.json.

Usage

Skeletons render with aria-hidden, so they are not announced individually. SkeletonGroup announces its label instead.

import { Skeleton, SkeletonGroup, SkeletonText } from '@/components/ui/skeleton';

<SkeletonGroup label="Loading members…">
  <Skeleton className="size-8 rounded-full" />
  <SkeletonText width="60%" />
  <SkeletonText variant="text-body-mini-regular" width="40%" />
</SkeletonGroup>

Skeleton Properties

PropTypeDefaultDescription
widthstring'100%'Width of the skeleton
heightstring'24px'Height of the skeleton
classNamestring—Additional CSS classes to apply to the skeleton
animatebooleantrueWhether to show the pulse animation
styleCSSProperties—Additional inline styles to apply to the skeleton

SkeletonText Properties

PropTypeDefaultDescription
variantTypographyClass—Typography class of the text that the line stands in for. Omit it to use the font size and line height of the parent
widthstring'100%'Approximate length of the text, as a CSS width
animatebooleantrueWhether to show the pulse animation
classNamestring—Layout classes, such as margin or alignment

SkeletonGroup Properties

PropTypeDefaultDescription
label (Required)string—Screen-reader loading announcement for the grouped skeletons
children (Required)ReactNode—Skeleton content rendered inside the group
classNamestring—Additional CSS classes to apply to the group container