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.
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.
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.
| Name | Type | Default | Description |
|---|---|---|---|
render | RenderProp<SkeletonState> | – | |
shape | SkeletonShape"line""block""circle" | 'line' |
- Also takes every attribute of
<span>exceptchildren. (Omit<ComponentPropsWithRef<"span">, "children">)
render takes an element, or, in client code, a function of the props and this state (SkeletonState):
| Name | Type | Default | Description |
|---|---|---|---|
shaperequired | SkeletonShape"line""block""circle" | – |
Other exports
SkeletonPropstypeimport type { SkeletonProps } from '@nizivo/react/skeleton'The props of
Skeleton, listed above.SkeletonShapetypeimport 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"SkeletonStatetypeimport 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.
| Slot | Rendered by | Data attributes |
|---|---|---|
skeleton.nz-skeleton | Skeletonroot (takes render) |
|
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.
| Hook | Default | Read as |
|---|---|---|
--nz-skeleton-bg | --nz-bg-muted |
|
--nz-skeleton-height | 1em |
|
--nz-skeleton-radius |
|
|
--nz-skeleton-width |
|
|
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.
- Canonical: Figma node
7275:15181 - Ghost masters: Figma node
756:1169
Sidebar
The app's main navigation on screens 640 px and wider, with the store at the top, the destinations, and Settings at the foot. It is 264 px wide from 1280 px and folds to a 72 px icon rail below that, where each destination's Tooltip names it.
Split
A main column and an aside, side by side while there is room and stacked below that, by the Split's own width, with no breakpoint and no script.