{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "success-check",
  "title": "Success check",
  "description": "Check or X in a circle that draws its stroke, fills, then pops with a ray-and-ring burst, for payment and booking result screens.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/feedback/success-check.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { GooduiTokens, spring, ease as easing } from \"@/lib/goodui-motion\"\n\nexport type SuccessCheckProps = Omit<React.ComponentProps<\"span\">, \"children\"> & {\n  /** \"success\" draws a check, \"error\" draws an X. */\n  variant?: \"success\" | \"error\"\n  /** Diameter in px. The burst reaches about 15% beyond it. */\n  size?: number\n  /** Rays and a ring that shoot outward once the mark lands. */\n  burst?: boolean\n  /** Seconds before the drawing starts. */\n  delay?: number\n  /** Change it to play the animation again. */\n  playKey?: React.Key\n  /** Accessible name. Defaults to \"Success\" or \"Error\". */\n  label?: string\n  /** Draws only the mark and burst, with no circle, and sooner: for a mark on a filled surface such as a button. */\n  plain?: boolean\n}\n\nconst RAYS = Array.from({ length: 8 }, (_, i) => {\n  const a = (i / 8) * Math.PI * 2 - Math.PI / 2 + Math.PI / 8\n  return { x1: 26 + Math.cos(a) * 29, y1: 26 + Math.sin(a) * 29, x2: 26 + Math.cos(a) * 34, y2: 26 + Math.sin(a) * 34 }\n})\n\n/** Check (or X) in a circle that draws itself in, fills, then pops with a ring burst. For payment and booking results. */\nexport function SuccessCheck({ variant = \"success\", size = 72, burst = true, delay = 0, playKey, label, plain = false, className, style, ...props }: SuccessCheckProps) {\n  // Read after mount: the server can't know the setting, so the first client render must match it.\n  const prefersReduced = useReducedMotion()\n  const [mounted, setMounted] = React.useState(false)\n  React.useEffect(() => setMounted(true), [])\n  const reduce = mounted && !!prefersReduced\n  const error = variant === \"error\"\n  // The circle takes the first .32s; a plain mark starts there instead.\n  const d = delay - (plain ? 0.32 : 0)\n  // Round caps paint a dot at pathLength 0, so every stroke stays transparent until its own draw starts.\n  const t = (base: number, duration: number) =>\n    reduce\n      ? { duration: 0 }\n      : { duration, delay: d + base, ease: easing.inOut, opacity: { duration: 0.01, delay: d + base } }\n  const draw = { initial: { pathLength: reduce ? 1 : 0, opacity: reduce ? 1 : 0 }, animate: { pathLength: 1, opacity: 1 } }\n\n  return (\n    <span\n      role=\"img\"\n      aria-label={label ?? (error ? \"Error\" : \"Success\")}\n      className={cn(\"relative inline-grid shrink-0 place-items-center\", error ? \"text-rose-500\" : \"text-emerald-500\", className)}\n      style={{ width: size, height: size, ...style }}\n      {...props}\n    >\n      <motion.svg\n        key={`${String(playKey ?? \"\")}-${variant}`}\n        viewBox=\"0 0 52 52\"\n        width={size}\n        height={size}\n        fill=\"none\"\n        className=\"overflow-visible\"\n        aria-hidden=\"true\"\n        initial={reduce ? false : { scale: 1 }}\n        animate={reduce ? undefined : { scale: [1, 1.08, 1] }}\n        transition={reduce ? undefined : { duration: 0.35, delay: d + 0.62, times: [0, 0.4, 1], ease: \"easeOut\" }}\n      >\n        {!plain && (\n          <>\n            <motion.circle\n              cx=\"26\"\n              cy=\"26\"\n              r=\"24\"\n              fill=\"currentColor\"\n              initial={reduce ? { opacity: 0.14, scale: 1 } : { opacity: 0, scale: 0.6 }}\n              animate={{ opacity: 0.14, scale: 1 }}\n              transition={reduce ? { duration: 0 } : { ...spring.play, delay: d + 0.28 }}\n            />\n            <motion.circle\n              cx=\"26\"\n              cy=\"26\"\n              r=\"24\"\n              stroke=\"currentColor\"\n              strokeWidth=\"2.5\"\n              strokeLinecap=\"round\"\n              transform=\"rotate(-90 26 26)\"\n              {...draw}\n              transition={t(0, 0.5)}\n            />\n          </>\n        )}\n        {error ? (\n          <>\n            <motion.path d=\"M18.5 18.5l15 15\" stroke=\"currentColor\" strokeWidth=\"3.5\" strokeLinecap=\"round\" {...draw} transition={t(0.42, 0.2)} />\n            <motion.path d=\"M33.5 18.5l-15 15\" stroke=\"currentColor\" strokeWidth=\"3.5\" strokeLinecap=\"round\" {...draw} transition={t(0.58, 0.2)} />\n          </>\n        ) : (\n          <motion.path\n            d=\"M15.5 27l7 7 14-15\"\n            stroke=\"currentColor\"\n            strokeWidth=\"3.5\"\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n            {...draw}\n            transition={t(0.42, 0.32)}\n          />\n        )}\n        {burst && !reduce && (\n          <>\n            <motion.circle\n              cx=\"26\"\n              cy=\"26\"\n              r=\"24\"\n              stroke=\"var(--pc-check-burst,currentColor)\"\n              strokeWidth=\"1.5\"\n              initial={{ opacity: 0, scale: 1 }}\n              animate={{ opacity: [0, 0.5, 0], scale: [1, 1, 1.4] }}\n              transition={{ duration: 0.7, delay: d + 0.6, times: [0, 0.1, 1], ease: \"easeOut\" }}\n            />\n            {RAYS.map((r, i) => (\n              <motion.line\n                key={i}\n                {...r}\n                stroke=\"var(--pc-check-burst,currentColor)\"\n                strokeWidth=\"2\"\n                strokeLinecap=\"round\"\n                initial={{ pathLength: 0, pathOffset: 0, opacity: 0 }}\n                // The first keyframe applies during the delay, so it must be invisible.\n                animate={{ pathLength: [0, 0, 1, 1], pathOffset: [0, 0, 0, 1], opacity: [0, 1, 1, 0] }}\n                transition={{ duration: 0.5, delay: d + 0.62, times: [0, 0.02, 0.45, 1], ease: \"easeOut\" }}\n              />\n            ))}\n          </>\n        )}\n      </motion.svg>\n    </span>\n  )\n}\n\nexport type SuccessButtonStatus = \"idle\" | \"loading\" | \"success\" | \"error\"\n\nexport type SuccessButtonLabels = { loading: string; success: string; error: string }\nconst DEFAULT_BUTTON_LABELS: SuccessButtonLabels = { loading: \"Working\", success: \"Done\", error: \"Failed\" }\n\nexport type SuccessButtonProps = Omit<React.ComponentProps<typeof motion.button>, \"children\"> & {\n  /** Drive it from your request: idle, then loading, then success or error, then idle again. */\n  status?: SuccessButtonStatus\n  /** Height in px; the button collapses into a circle of this size. */\n  size?: number\n  children?: React.ReactNode\n  /** Announced to screen readers; pass translations here. */\n  labels?: Partial<SuccessButtonLabels>\n}\n\n/** The check grows out of the button itself: the label blurs away, the button folds into a circle and the mark draws on it. */\nexport function SuccessButton({ status = \"idle\", size = 40, labels, className, style, onClick, children, ...props }: SuccessButtonProps) {\n  const l = useLabels(\"success-check-button\", DEFAULT_BUTTON_LABELS, labels)\n  const reduce = useReducedMotion() ?? false\n  const idle = status === \"idle\"\n  const morph = reduce ? { duration: 0 } : spring.morph\n  const swap = {\n    initial: reduce ? { opacity: 0 } : { opacity: 0, filter: \"blur(4px)\" },\n    animate: { opacity: 1, filter: \"blur(0px)\" },\n    exit: reduce ? { opacity: 0 } : { opacity: 0, filter: \"blur(4px)\" },\n    transition: { duration: reduce ? 0 : 0.16 },\n  }\n  return (\n    <motion.button\n      type=\"button\"\n      layout\n      data-status={status}\n      aria-busy={status === \"loading\"}\n      aria-disabled={!idle}\n      onClick={(e) => {\n        if (idle) onClick?.(e)\n      }}\n      animate={{ borderRadius: idle ? 10 : size / 2 }}\n      transition={morph}\n      className={cn(\n        \"pc-press relative inline-flex cursor-pointer items-center justify-center bg-primary text-sm font-medium whitespace-nowrap text-primary-foreground shadow-[var(--pc-e1)] transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50 data-[status=error]:bg-rose-600 data-[status=error]:text-white data-[status=error]:[--pc-check-burst:var(--color-rose-500)] data-[status=success]:bg-emerald-600 data-[status=success]:text-white data-[status=success]:[--pc-check-burst:var(--color-emerald-500)]\",\n        idle && \"px-5\",\n        className,\n      )}\n      style={{ height: size, width: idle ? undefined : size, ...style }}\n      {...props}\n    >\n      <GooduiTokens />\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        {status === \"idle\" ? (\n          <motion.span key=\"idle\" layout=\"position\" className=\"inline-flex items-center gap-2\" {...swap}>\n            {children}\n          </motion.span>\n        ) : status === \"loading\" ? (\n          <motion.svg key=\"loading\" viewBox=\"0 0 24 24\" fill=\"none\" className=\"size-[45%]\" aria-hidden=\"true\" animate={{ ...swap.animate, rotate: 360 }} initial={swap.initial} exit={swap.exit} transition={{ ...swap.transition, rotate: { duration: reduce ? 2.4 : 0.8, repeat: Infinity, ease: \"linear\" } }}>\n            <circle cx=\"12\" cy=\"12\" r=\"9\" stroke=\"currentColor\" strokeOpacity=\".3\" strokeWidth=\"3\" />\n            <path d=\"M21 12a9 9 0 0 0-9-9\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" />\n          </motion.svg>\n        ) : (\n          <motion.span key={status} className=\"grid place-items-center\" {...swap}>\n            <SuccessCheck plain variant={status === \"error\" ? \"error\" : \"success\"} size={size} className=\"text-current\" aria-hidden=\"true\" />\n          </motion.span>\n        )}\n      </AnimatePresence>\n      <span className=\"sr-only\" role=\"status\">\n        {idle ? \"\" : l[status]}\n      </span>\n    </motion.button>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/success-check.tsx"
    }
  ],
  "categories": [
    "components",
    "feedback"
  ],
  "type": "registry:component"
}