Skip to content
Nizivo UI

Skeleton

One placeholder block, always hidden from assistive technology. The region it stands in for sets aria-busy and carries visually hidden "Loading …" text (§16.5). There is no style prop path: size it with a class, or with --nz-skeleton-width, --nz-skeleton-height and --nz-skeleton-radius.

Server component, no client JS

Import

import { Skeleton } from '@nizivo/react/skeleton';

// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/skeleton.css';

Static or interactive

Server. It ships no client JavaScript when a Server Component renders it, in every Next.js build mode; its code is bundled only when a client component (a 'use client' file) imports it. The pulse is a CSS animation. How to choose.

In a client app (a Vite or React Router single-page app, or a 'use client' file) it is an ordinary React component: event handlers, refs and state work as usual. In a client app.

Examples

Basic

Figma Shape=Line: the region being loaded is busy and says so; the blocks are hidden.

Loading orders
import type { JSX } from 'react';
import { Skeleton } from '@nizivo/react/skeleton';

export function SkeletonExample(): JSX.Element {
  return (
    <div aria-busy="true">
      <span className="nz-visually-hidden">Loading orders</span>
      <Skeleton />
      <Skeleton className="orders-skeleton-short" />
      <Skeleton className="orders-skeleton-shorter" />
    </div>
  );
}

Props

One placeholder block, always hidden from assistive technology. The region it stands in for sets aria-busy and carries visually hidden "Loading …" text (§16.5). There is no style prop path: size it with a class, or with --nz-skeleton-width, --nz-skeleton-height and --nz-skeleton-radius.

Server component Renders data-slot="skeleton" with the class nz-skeleton. Props: SkeletonProps. Source: src/skeleton/skeleton.tsx.

NameTypeDefaultDescription
renderRenderProp<SkeletonState>–
shapeSkeletonShape
"line""block""circle"
'line'
  • Also takes every attribute of <span> except children. (Omit<ComponentPropsWithRef<"span">, "children">)

render takes an element, or, in client code, a function of the props and this state (SkeletonState):

NameTypeDefaultDescription
shaperequiredSkeletonShape
"line""block""circle"
–

Other exports

SkeletonProps type

import type { SkeletonProps } from '@nizivo/react/skeleton'

The props of Skeleton, listed above.

SkeletonShape type

import type { SkeletonShape } from '@nizivo/react/skeleton'

Figma "Shape": a text line, a block (media, a chart) or a circle (an avatar).

type SkeletonShape = "line" | "block" | "circle"

SkeletonState type

import type { SkeletonState } from '@nizivo/react/skeleton'

The render state of Skeleton, listed above.

Data attributes and slots

Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.

SlotRendered byData attributes
skeleton
.nz-skeleton
Skeleton
root (takes render)
  • data-shape: "line""block""circle" ← shape
    The shape prop; values in each component manifest (Skeleton: line, block, circle)

CSS hooks

Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.

HookDefaultRead as
--nz-skeleton-bg--nz-bg-muted
  • background on .nz-skeleton
--nz-skeleton-height1em
  • block-size on .nz-skeleton
  • --_nz-skeleton-width on .nz-skeleton[data-shape="circle"]
--nz-skeleton-radius
  • default: var(--nz-radius-xs)
  • data-shape="block": var(--nz-radius-sm)
  • data-shape="circle": var(--nz-radius-full)
  • border-radius on .nz-skeleton
--nz-skeleton-width
  • default: 100%
  • data-shape="circle": var(--nz-skeleton-height, 1em)
  • inline-size on .nz-skeleton

Layers: nz.components. Classes: .nz-skeleton.

Tokens this stylesheet reads (5)

--nz-bg-muted, --nz-duration-pulse, --nz-radius-full, --nz-radius-sm, --nz-radius-xs

Accessibility

Nothing in this component takes focus or keyboard input.

Keyboard

None.

Figma

Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.

On this page