Skip to main content
Clever Ops

Generative Skeleton

A streaming placeholder that morphs, shimmering blocks resize and settle into real headings, rows, and cards as each section's content lands, so the answer arrives without a layout jump.

Preview & code

Loading Generative Skeleton preview

Installation

pnpm dlx shadcn@latest add @cleverui/generative-skeleton

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { GenerativeSkeleton } from '@/components/ui/generative-skeleton'
Exampletsx
'use client'

import { useEffect, useMemo, useState } from 'react'
import { useReducedMotion } from 'motion/react'
import {
  GenerativeSkeleton,
  type GenerativeSection,
} from '@/components/ui/generative-skeleton'

/** Meridian incident summary, content lands on a deterministic schedule. */
const FINAL: GenerativeSection[] = [
  {
    id: 'title',
    kind: 'heading',
    content: 'Incident INC-8841, duplicate Stripe charge',
  },
  {
    id: 'p1',
    kind: 'paragraph',
    lines: 3,
    content:
      'Acme Logistics was charged $1,240 twice on the March close pack. Xero shows one open invoice and one paid twin sharing the same Stripe payment intent.',
  },
  {
    id: 'p2',
    kind: 'paragraph',
    lines: 2,
    content:
      'Customer ops ticket #4412 confirms the duplicate. Finance asks for a full refund to the original card before the close window locks.',
  },
  {
    id: 'r1',
    kind: 'row',
    content: 'Stripe charge · $1,240.00',
  },
  {
    id: 'r2',
    kind: 'row',
    content: 'Xero open invoice · inv_2026_03_8841',
  },
  {
    id: 'r3',
    kind: 'row',
    content: 'Refund path · stripe.refunds.create',
  },
  {
    id: 'card',
    kind: 'card',
    content:
      'Totals: $1,240 proposed refund · medium risk · controller gate at $500 still applies if the agent auto-executes without HITL.',
  },
]

/** Staged land times (ms from mount) for each section index */
const LAND_AT = [400, 900, 1400, 1900, 2300, 2700, 3200]

export default function GenerativeSkeletonDemo() {
  const reduced = useReducedMotion()
  const [landed, setLanded] = useState<Record<string, boolean>>({})

  const sections = useMemo(
    () =>
      FINAL.map((s) =>
        landed[s.id] || reduced
          ? s
          : { id: s.id, kind: s.kind, lines: s.lines }
      ),
    [landed, reduced]
  )

  useEffect(() => {
    if (reduced) {
      const all: Record<string, boolean> = {}
      for (const s of FINAL) all[s.id] = true
      setLanded(all)
      return
    }

    const timers: number[] = []
    FINAL.forEach((s, i) => {
      const delay = LAND_AT[i] ?? 3000 + i * 400
      timers.push(
        window.setTimeout(() => {
          setLanded((prev) => ({ ...prev, [s.id]: true }))
        }, delay)
      )
    })

    return () => {
      for (const t of timers) window.clearTimeout(t)
    }
  }, [reduced])

  return (
    <div className="mx-auto flex min-h-[480px] w-full max-w-xl flex-col justify-center px-4 py-12 sm:px-6 sm:py-16">
      <div className="rounded-2xl border border-border/60 bg-card p-5 sm:p-6">
        <p className="mb-5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground sm:text-xs">
          meridian-ops · streaming draft
        </p>
        <GenerativeSkeleton
          sections={sections}
          label="Generating"
          doneLabel="Draft ready"
        />
      </div>
    </div>
  )
}

API reference

GenerativeSkeleton accepts the following props.

PropTypeDefaultDescription
sections*GenerativeSection[]anticipated shape of the answer; content undefined = pending placeholder
labelstring'Generating'mono micro-label above the stack
doneLabelstring'Draft ready'quiet label once all sections have landed
onSettled() => voidfires once when the last pending section receives content

…plus everything from React.HTMLAttributes<HTMLDivElement>: className, event handlers, aria attributes and the rest pass straight through.

Referenced types

Typestsx
export interface GenerativeSection {
  id: string
  kind: GenerativeSectionKind
  /** when undefined, renders a shimmer-sized placeholder for this kind */
  content?: string
  /** line count for paragraph placeholders; ignored once content lands */
  lines?: number
}

export type GenerativeSectionKind = 'heading' | 'paragraph' | 'row' | 'card'

Frequently asked questions

How do I install the Generative Skeleton component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/generative-skeleton`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Generative Skeleton require?

Generative Skeleton uses motion on top of React and Tailwind CSS. You don't need to install it manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Generative Skeleton to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services