Skip to Content
CodeUI

Skeleton

@codeui/solid v0.3.0

A placeholder shape shown while content loads.

When to use

Use Skeleton where a snippet preview or metadata will appear. Matching the loaded content dimensions keeps the layout steady.

When to choose another component

Use Spinner for a compact busy indicator inside a control. Use Progress for a task with a measurable value.

Live demo

skeleton/basic.tsx
import { Skeleton, Stack } from "@codeui/solid";

export default function Demo() {
	return (
		<section aria-label="Snippet preview" aria-busy="true">
			<Stack gap="2">
				<Skeleton width="60%" height="1rem" />
				<Skeleton height="4rem" />
			</Stack>
		</section>
	);
}

Anatomy

Tap a part to outline it in the demo.

  1. 01Rootskeletonclasses.root
ExportRendersclasses keydata-cuiRole
Rootdivrootskeletongroup

Variants

Shapes and dimensions

skeleton/shapes.tsx
import { Skeleton, Stack } from "@codeui/solid";

export default function Demo() {
	return (
		<section aria-label="Snippet details" aria-busy="true">
			<Stack gap="3">
				<Skeleton circle height="var(--cui-space-10)" />
				<Skeleton width="60%" height="1rem" />
				<Skeleton height="4rem" radius="var(--cui-radius-md)" />
			</Stack>
		</section>
	);
}

width, height, and radius accept CSS values. Width defaults to 100% and height to auto. A circle uses height for width, falling back to width.

Animation

skeleton/animation.tsx
import { Skeleton, Stack } from "@codeui/solid";

export default function Demo() {
	return (
		<section aria-label="Snippet previews" aria-busy="true">
			<Stack gap="3">
				<Skeleton animate height="2rem" />
				<Skeleton animate={false} height="2rem" />
			</Stack>
		</section>
	);
}

animate defaults to true. Set it to false for a static placeholder. Reduced motion also disables the pulse.

States

skeleton/revealed.tsx
import { Button, Skeleton, Stack } from "@codeui/solid";
import { createSignal } from "solid-js";

export default function Demo() {
	const [loading, setLoading] = createSignal(true);
	return (
		<Stack gap="3">
			<Button variant="secondary" onClick={() => setLoading(!loading())}>
				{loading() ? "Reveal snippet" : "Load again"}
			</Button>
			<section aria-label="Snippet title" aria-busy={loading() ? "true" : "false"}>
				<Skeleton visible={loading()}>
					<span>Gradient editor.tsx</span>
				</Skeleton>
			</section>
		</Stack>
	);
}

visible defaults to true. Set it to false when content is ready. The children remain mounted while the placeholder is visible.

Ready API

Skeleton

Skeleton renders Root with CSS dimensions. style merges after width, height, and radius, so matching inline style properties take precedence.

Prop

Type

Inherited behavior from Kobalte skeleton.

Prop

Type

Styled parts API

Import the parts from @codeui/solid/skeleton/parts. The root wraps Kobalte skeleton.

Root

Styled Kobalte Skeleton root. It hides the visible placeholder from assistive technology. Its inherited dimensions use numeric pixel values; the ready Skeleton accepts CSS values.

Prop

Type

Prop

Type

Styles export

skeletonStyles

skeletonStyles is typed as SkeletonStyles. Each part function returns a class string. Use it when you own the markup and semantics. root({ circle, animate }) selects the shape and pulse. Styles alone do not provide visibility attributes or hide content from screen readers.

Accessibility

Keyboard

Skeleton is non-interactive and has no keyboard commands. It does not add a tab stop.

ARIA

Kobalte Root renders role="group". While visible is true, Root has aria-hidden="true". When visible={false}, the kit removes that attribute and reveals the children. The loading region owns aria-busy; Skeleton does not add it. Hidden placeholder content is not an announcement.

Focus

Mounting or removing the component does not move focus. There is no open or close focus cycle. The reveal example keeps its toggle outside the loading region so focus stays available.

Reduced motion

Visible placeholders pulse when animate is true. Under prefers-reduced-motion: reduce, the pulse stops and the shape stays visible. Visibility and ARIA behavior stay the same.

SSR notes

The component renders inline on the server. It has no portal or client-only effect. Use the same initial props on the server and client. The server renders the placeholder or revealed content from visible. CSS handles the pulse and reduced motion.

Theming hooks

The component reads these theme variables.

  • --cui-action-neutral-base
  • --cui-motion-duration-slow
  • --cui-motion-ease-out
  • --cui-radius-full
  • --cui-radius-xs

Defaults come from the kit theme. See Color, Typography, Space and shape, and Motion.

Composition examples

The demo under States composes Skeleton with a loading region. The button toggles visible and the loading region's aria-busy together. The title becomes accessible when the placeholder disappears. Keep interactive controls outside hidden loading content.

Use Spinner for a compact busy indicator inside a control. Use Progress for a task with a measurable value.

On this page