{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "skeleton-shimmer",
  "title": "Skeleton Shimmer",
  "description": "Skeleton loading placeholders with a shimmer effect that transitions to revealed content via a CSS view-transition wipe animation. Skeletons are sized using placeholder data to reduce layout shifts.",
  "dependencies": ["motion"],
  "registryDependencies": ["utils"],
  "files": [
    {
      "path": "registry/primitives/effects/skeleton-shimmer/index.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion, useReducedMotion } from \"motion/react\";\nimport type { HTMLMotionProps } from \"motion/react\";\nimport { useInsertionEffect } from \"react\";\nimport type { CSSProperties, ReactNode, Ref } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Theme-aware shimmer surface\n//\n// `--sk-shimmer-from` is the block fill; `--sk-shimmer-to` is the moving\n// highlight. Both default to the app's `--muted` / `--foreground` tokens so\n// the sweep stays visible on light and dark surfaces. Override either var\n// (className or style) to retint.\n// ---------------------------------------------------------------------------\n\nconst SHIMMER_FROM =\n  \"var(--sk-shimmer-from, color-mix(in oklab, var(--foreground, #111) 10%, var(--muted, #e8eaed)))\";\nconst SHIMMER_TO =\n  \"var(--sk-shimmer-to, color-mix(in oklab, var(--foreground, #111) 22%, var(--muted, #e8eaed)))\";\nconst SHIMMER_BG_IMAGE = `linear-gradient(90deg, ${SHIMMER_FROM} 25%, ${SHIMMER_TO} 50%, ${SHIMMER_FROM} 75%)`;\n\nconst SHIMMER_KEYFRAMES = {\n  backgroundPosition: [\"-200% 0\", \"200% 0\"],\n};\n\nfunction getShimmerSurfaceStyle(\n  borderRadius: number | string | undefined,\n  style?: CSSProperties\n): CSSProperties {\n  return {\n    backgroundColor: SHIMMER_FROM,\n    backgroundImage: SHIMMER_BG_IMAGE,\n    backgroundSize: \"200% 100%\",\n    borderRadius,\n    ...style,\n  };\n}\n\n// ---------------------------------------------------------------------------\n// SkeletonShimmer — standalone animated shimmer block primitive\n// ---------------------------------------------------------------------------\n\nexport interface SkeletonShimmerProps extends HTMLMotionProps<\"div\"> {\n  /**\n   * Whether the shimmer animation is active.\n   * @default true\n   */\n  animate?: boolean;\n  /**\n   * Border radius for the shimmer container.\n   */\n  borderRadius?: number | string;\n  /**\n   * Additional CSS class names. Override `--sk-shimmer-from` / `--sk-shimmer-to`\n   * here to retint the block fill and highlight.\n   */\n  className?: string;\n  /**\n   * Shimmer sweep duration in seconds.\n   * @default 1.5\n   */\n  duration?: number;\n  /**\n   * Ref forwarded to the underlying motion element.\n   */\n  ref?: Ref<HTMLDivElement>;\n  /**\n   * Optional custom inline styles.\n   */\n  style?: CSSProperties;\n}\n\n/**\n * A GPU-accelerated shimmer block primitive.\n * Respects `prefers-reduced-motion` automatically.\n */\nexport function SkeletonShimmer({\n  duration = 1.5,\n  borderRadius,\n  className,\n  style,\n  animate: shouldAnimate = true,\n  ref,\n  ...props\n}: SkeletonShimmerProps) {\n  const prefersReducedMotion = useReducedMotion();\n  const isAnimated = shouldAnimate && !prefersReducedMotion;\n\n  return (\n    <motion.div\n      animate={isAnimated ? SHIMMER_KEYFRAMES : undefined}\n      className={cn(\"overflow-hidden\", className)}\n      ref={ref}\n      style={getShimmerSurfaceStyle(borderRadius, style)}\n      transition={{\n        duration,\n        ease: \"easeInOut\",\n        repeat: Number.POSITIVE_INFINITY,\n      }}\n      {...props}\n    />\n  );\n}\n\n// ---------------------------------------------------------------------------\n// SkeletonOverlay — zero-layout-shift shimmer wrapper\n// Sizes itself dynamically using hidden children (eliminates CLS)\n// ---------------------------------------------------------------------------\n\nexport interface SkeletonOverlayProps extends HTMLMotionProps<\"div\"> {\n  /**\n   * Whether the shimmer animation is active.\n   * @default true\n   */\n  animate?: boolean;\n  /**\n   * Border radius for the shimmer container.\n   * @default \"6px\"\n   */\n  borderRadius?: number | string;\n  /**\n   * Children whose layout and dimensions define the skeleton's bounding box.\n   */\n  children: ReactNode;\n  /**\n   * Additional CSS class names. Override `--sk-shimmer-from` / `--sk-shimmer-to`\n   * here to retint the block fill and highlight.\n   */\n  className?: string;\n  /**\n   * Shimmer sweep duration in seconds.\n   * @default 1.5\n   */\n  duration?: number;\n  /**\n   * Ref forwarded to the underlying motion element.\n   */\n  ref?: Ref<HTMLDivElement>;\n  /**\n   * Optional custom inline styles.\n   */\n  style?: CSSProperties;\n}\n\n/**\n * Shimmer wrapper that hides its children visually with `visibility: hidden`\n * while using their exact dimensions to size itself. Guarantees 0 layout shift\n * when transitioning from loading state to revealed content.\n */\nexport function SkeletonOverlay({\n  children,\n  duration = 1.5,\n  borderRadius = \"6px\",\n  className,\n  style,\n  animate: shouldAnimate = true,\n  ref,\n  ...props\n}: SkeletonOverlayProps) {\n  const prefersReducedMotion = useReducedMotion();\n  const isAnimated = shouldAnimate && !prefersReducedMotion;\n\n  return (\n    <motion.div\n      animate={isAnimated ? SHIMMER_KEYFRAMES : undefined}\n      className={cn(\"min-h-min overflow-hidden\", className)}\n      ref={ref}\n      style={getShimmerSurfaceStyle(borderRadius, style)}\n      transition={{\n        duration,\n        ease: \"easeInOut\",\n        repeat: Number.POSITIVE_INFINITY,\n      }}\n      {...props}\n    >\n      {/* Children are invisible but maintain normal flow and dimensions */}\n      <div aria-hidden=\"true\" style={{ visibility: \"hidden\" }}>\n        {children}\n      </div>\n    </motion.div>\n  );\n}\n\n// ---------------------------------------------------------------------------\n// View Transition Wipe CSS & Hook Helper\n// Allows easily applying the right-to-left mask wipe on any view transition layer\n// ---------------------------------------------------------------------------\n\nexport const VIEW_TRANSITION_WIPE_CSS = `\n@property --sk-wipe {\n  syntax: '<percentage>';\n  inherits: true;\n  initial-value: -100%;\n}\n\n::view-transition-group(skeleton-card) {\n  border-radius: 16px;\n  overflow: hidden;\n}\n\n::view-transition-image-pair(skeleton-card) {\n  mix-blend-mode: normal;\n}\n\n::view-transition-old(skeleton-card) {\n  z-index: 2;\n  mask-image: linear-gradient(\n    to right,\n    black var(--sk-wipe),\n    transparent calc(var(--sk-wipe) + 100%)\n  );\n  animation: sk-wipe-out 0.6s ease-in-out forwards;\n}\n\n::view-transition-new(skeleton-card) {\n  animation: none;\n}\n\n@keyframes sk-wipe-out {\n  from { --sk-wipe: 100%; }\n  to   { --sk-wipe: -100%; }\n}\n`;\n\nlet wipeStylesInjected = false;\n\nexport function useViewTransitionWipeStyles() {\n  useInsertionEffect(() => {\n    if (wipeStylesInjected) {\n      return;\n    }\n    wipeStylesInjected = true;\n    const el = document.createElement(\"style\");\n    el.textContent = VIEW_TRANSITION_WIPE_CSS;\n    document.head.append(el);\n  }, []);\n}\n\nexport default SkeletonShimmer;\n",
      "type": "registry:ui",
      "target": "components/sora-ui/effects/skeleton-shimmer.tsx"
    }
  ],
  "meta": {
    "keywords": [
      "skeleton",
      "shimmer",
      "loading",
      "placeholder",
      "view-transition",
      "wipe"
    ],
    "inspiration": {
      "type": "reimplemented",
      "label": "motion.dev skeleton-shimmer",
      "url": "https://examples.motion.dev/react/skeleton-shimmer"
    }
  },
  "type": "registry:ui"
}
