Skip to content
Nana UI

Feedback & Status

Skeleton

A placeholder that mimics the shape of content while it loads. Supports text lines, circles (avatars), and rectangles (images/cards) with shimmer, pulse, or wave animations. When loading becomes false the skeleton fades out smoothly.

View .md Download

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add skeleton --framework web-components
npx @nana-tec/ui add skeleton --framework svelte

Lands in src/lib/components/ui/skeleton/ as NanaSkeleton.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/skeleton";

Copied in with npx @nana-tec/ui add skeleton? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<script lang="ts">
import { NanaSkeleton } from '$lib/components/ui/skeleton';
let { invoice } = $props();
</script>
<NanaSkeleton count={3} loading={!invoice}>
<p>{invoice.description}</p>
</NanaSkeleton>

While loading is true it draws placeholder lines, the last one shorter, and marks itself busy; then it renders its children instead. shape is text, circle or rect.

<nana-skeleton style="width:220px;height:1rem"></nana-skeleton>

Use count to render several placeholder lines.

Properties

PropertyAttributeTypeDefaultDescription
animationanimationSkeletonAnimation'shimmer'Animation style — shimmer, pulse, wave, or none
countcountnumber1Number of skeleton items to render
loadingloadingbooleantrueWhen false the skeleton fades out and slotted content is visible
shapeshapeSkeletonShape'text'Shape of the skeleton placeholder
sizesizeSkeletonSize'md'Relative size

Slots

SlotDescription
(default)Optional content revealed when loading completes

CSS parts

PartDescription
::part(base)Each skeleton item
::part(wrapper)The container wrapping all items (when count > 1)
::part(root)The skeleton and its content
::part(shapes)The placeholder shapes together
::part(content)The real content once loaded

CSS custom properties

PropertyDescription
--nana-skeleton-radiusCorner radius override
--nana-skeleton-heightHeight override
--nana-skeleton-widthWidth override
--nana-skeleton-gapGap between items when count > 1
--nana-skeleton-fade-durationFade-out transition duration (default 200ms)

NanaSkeleton

PropTypeDefault
shapeSkeletonShape'text'
sizeSkeletonSize'md'
animationSkeletonAnimation'pulse'
countnumber1
loadingbooleantrue
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class'>.