import * as React from "react"; import { cn } from "@/lib/utils"; interface SkeletonProps extends React.HTMLAttributes { /** Pulse start delay in milliseconds, used by SkeletonGroup for stagger. */ delay?: number; } function Skeleton({ className, delay, style, ...props }: SkeletonProps) { return (
); } interface SkeletonGroupProps extends React.HTMLAttributes { /** Gap between each child animation start, default 80ms. */ stagger?: number; } /** * Wraps multiple Skeleton children and assigns incremental animation-delay to * each one, producing a progressive loading effect. */ function SkeletonGroup({ children, stagger = 80, className, ...props }: SkeletonGroupProps) { const items = React.Children.toArray(children); return (
{items.map((child, index) => { if (!React.isValidElement(child)) return child; const existingDelay = child.props.delay ?? 0; return React.cloneElement(child, { delay: existingDelay + index * stagger, }); })}
); } export { Skeleton, SkeletonGroup };