rapidUI

Skeleton

Animated placeholder shown while content loads.

Installation

pnpm dlx shadcn@latest add https://rdf.dev.360online.com/r/skeleton.json

Installs to @/components/ui/skeleton.

Manual installation

Copy the source into your project:

components/ui/skeleton.tsx
import { cn } from '@/lib/utils'

function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
	return <div data-slot="skeleton" className={cn('animate-pulse rounded-md bg-muted', className)} {...props} />
}

export { Skeleton }

A skeleton component to display a placeholder loading state for content that is yet to load.

Features

  • A plain div with animate-pulse, rounded-md and the muted background (bg-muted)
  • Customizable dimensions and shape via className
  • Composable for complex loading states
  • data-slot="skeleton" for styling hooks

Usage

import { Skeleton } from "@/components/ui/skeleton"

export function LoadingProfile() {
  return (
    <div className="flex items-center gap-4">
      <Skeleton className="size-12 rounded-full" />
      <div className="space-y-2">
        <Skeleton className="h-4 w-[250px]" />
        <Skeleton className="h-4 w-[200px]" />
      </div>
    </div>
  )
}

Examples

Default

A case handler loading: an avatar circle and two lines of text. The wrapper is marked aria-busy and carries a visually hidden status message.

Card

A building permit card while it loads, keeping the header, preview, body text and footer actions in place so nothing jumps when the content arrives.

List

A case list with avatars, titles, reference lines and status badges.

Form

An e-service application form waiting for prefilled resident data.

Stats

Dashboard tiles for open, due and closed cases.

Anatomy

<Skeleton className="h-4 w-[250px]" />

Props

Skeleton

The root component that renders a skeleton placeholder.

Accessibility

The Skeleton is purely visual and sets no ARIA attributes itself. To communicate loading to assistive technology:

  • Mark the loading region with aria-busy="true" and restore it when content arrives
  • Optionally add a visually hidden status message (e.g. <span className="sr-only">Loading...</span>)
  • Respect reduced motion, e.g. motion-reduce:animate-none

Best Practices

  1. Match skeleton dimensions to actual content
  2. Use appropriate spacing and layout
  3. Keep animations subtle and not distracting
  4. Group related skeleton elements
  5. Consider mobile responsiveness

Customization

Custom Dimensions

Adjust the width and height using Tailwind classes:

<Skeleton className="h-8 w-32" />

Custom Shape

Modify the border radius using Tailwind classes:

<Skeleton className="h-12 w-12 rounded-full" /> // Circle
<Skeleton className="h-24 w-full rounded-xl" /> // Rounded rectangle

Custom Animation

The default pulse animation can be customized through Tailwind:

<Skeleton className="animate-[pulse_2s_ease-in-out_infinite]" />
  • Progress - For determinate loading states
  • Spinner - For inline loading indicators
  • Card - For content layouts that might need skeleton states