Components / Skeleton
Skeleton
Reserve the shape of content while it is loading. Compose square, decorative placeholders with your own dimensions, then replace them with the content when it is ready.
Storybook runs locally or as a separately hosted build; no hosted Storybook is configured. Source and setup links match the install revision.
Usage playground
Preview a profile waiting for content, then replace its placeholders with local content. You control the transition; this example makes no request and runs no timer. In an application, use your actual loading state.
Contributor profile
Profile preview pending.
'use client';
import { useId, useState } from 'react';
import { Skeleton } from "@/components/ui/yads-skeleton";
const layout = { display: 'grid', gap: '1rem', width: '100%', maxWidth: '24rem', minWidth: 0 } as const;
Installation
pnpm dlx [email protected] add biehlio/yet-another-design-system/skeleton#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40This revision-pinned command installs yads-skeleton and its scoped stylesheet, with no package dependencies. Import { Skeleton } from @/components/ui/yads-skeleton (adjust your alias). No Tailwind, reset, font install, global CSS or theme provider is required. Light is the default; the nearest explicit light/dark boundary wins. See API reference for native @scope browser support.
Copy sample copies a complete React module, including layout and recipe CSS, even when collapsed. Samples need only this registry item; interactive modules include a client boundary. Playground controls are documentation controls, not extra Skeleton props.
Composed placeholders
Match the shape of the expected content with consumer-defined dimensions. This square 48px portrait and two 16px text bars shrink within their container. Skeleton has no default width or height, avatar mode or text API. Reserve space in your layout to limit shifts when content arrives.
'use client';
import { useId, useState } from 'react';
import { Skeleton } from "@/components/ui/yads-skeleton";
const layout = { display: 'grid', gap: '1rem', width: '100%', maxWidth: '24rem', minWidth: 0 } as const;
className customization
Size placeholders with style or a scoped class. This recipe keeps theme colors, disables the article block’s pulse and leaves the text bars animated unless reduced motion is requested. No shimmer configuration is needed.
'use client';
import { useId, useState } from 'react';
import { Skeleton } from "@/components/ui/yads-skeleton";
const layout = { display: 'grid', gap: '1rem', width: '100%', maxWidth: '24rem', minWidth: 0 } as const;
Accessibility
- Keep placeholders decorative. Every Skeleton has aria-hidden="true" and inert. It has no accessible name, status or progressbar role, keyboard behavior or Tab stop. Do not put text, controls or meaningful content inside it or attach interaction to it.
- The containing region owns loading. Name the content region and set its aria-busy from your real loading state. If useful, associate persistent status text through aria-describedby. Put a separate role="status" outside the busy region so it can communicate meaningful changes. Avoid announcing every placeholder.
- Replace, do not conceal content. Render the content instead when it is ready. Skeleton does not fetch, track loading, manage focus, handle errors or announce completion. Keep any retry or cancel controls outside it.
- Respect reduced motion. The opacity pulse stops under prefers-reduced-motion: reduce; an opaque static shape remains. For long waits, consider a static recipe (as in customization) or application-level motion control. Reduced motion does not change your loading state.
Use Progress for a task’s measurable completion or an explicitly named indeterminate indicator. Skeleton only suggests content geometry; it cannot convey an amount of work.
API reference
Import { Skeleton, type SkeletonProps } from @/components/ui/yads-skeleton. SkeletonProps follows React.HTMLAttributes<HTMLDivElement>, excluding children, dangerouslySetInnerHTML, tabIndex, role, contentEditable, aria-hidden, aria-live and inert. These exclusions preserve the empty decorative contract. Other native attributes and the div ref are forwarded; event handlers may be passed but inert prevents user interaction.
On narrow screens, focus the table and scroll horizontally to read all columns.
| Prop | Type | Default | Description |
|---|---|---|---|
className / style | string / CSSProperties | Not set | Consumer-defined dimensions and layout. Scoped root class is retained. No default width or height. |
ref | React.Ref<HTMLDivElement> | Not set | Forwarded to the real div for measurement; it is not a focus target. |
Native div attributes | SkeletonProps | Not set | id, title, data-* and other supported native div props pass through. There is no loading, value, size or text prop. |
aria-hidden / inert | Fixed by component | true | Decorative and noninteractive. Not configurable. role, tabIndex, contentEditable and aria-live are excluded and cleared. |
children / dangerouslySetInnerHTML | Not supported | Empty | Skeleton is an empty placeholder, never a wrapper for meaningful content or controls. |
Themes, fonts and browser support
Light is the standalone default. The nearest explicit theme wins: .dark or data-theme="dark" enables dark colors; .light or data-theme="light" stops an outer dark scope. data-theme takes precedence when present. Changing these boundaries updates live, without a provider. Scoped CSS uses native @scope: use browsers with @scope support (Chrome/Edge 118+, Safari 17.4+, Firefox 146+). Without it, the light base remains; dark theming requires @scope. Native inert is also required for the noninteractive boundary.
No font dependency is installed or imported: an empty decorative shape renders no typography. Surrounding content uses your application’s font. No Tailwind, reset, global tokens, site CSS or provider is required.
Playground defaults and limitations
Reset returns to placeholders. Show profile replaces them with local profile content and clears aria-busy on the region; Show placeholders restores them. Preview state chooses the initial state copied into the module. The page owns its status text. There is no timer, request, artificial progress, polymorphic asChild, animation variant or loading lifecycle API.