Skeleton

A placeholder shown while content loads.

import { ... } from '@corndev/ui'

HTML

No JavaScript required — these classes are the whole component.

<div class="corn-skeleton" data-variant="text"></div>

Classes

Class
.corn-skeleton

Attributes

AttributeValues
data-varianttext|rectangular|circular

Vanilla JS

Optional. createSkeleton only adds and removes the classes and attributes above, so the HTML is equivalent. Reach for it when you need to change options at runtime.

import { createSkeleton } from '@corndev/ui';
import '@corndev/ui/theme';

const el = document.querySelector('#target');
const instance = createSkeleton(el, { /* options */ });

Options

OptionTypeDefaultDescription
variant'text'|'rectangular'|'circular''text'
widthnumber|stringundefinedCSS width (number → px).
heightnumber|stringundefinedCSS height (number → px).

React

Skeleton — from @corndev/ui-react.

The props are the same as the options above, plus className.

A skeleton is a low-contrast placeholder that mirrors the shape of content while it loads, reducing layout shift. It’s decorative (aria-hidden), so keep a separate role="status"/Spinner for the announced loading state.

Usage

import { Skeleton } from '@corndev/ui-react';

<Skeleton />                                       {/* text line */}
<Skeleton variant="text" width="60%" />
<Skeleton variant="circular" width={48} height={48} />
<Skeleton variant="rectangular" width="100%" height={160} />
import { createSkeleton } from '@corndev/ui';
createSkeleton(document.querySelector('#ph'), { variant: 'rectangular', height: 160 });