{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stepper",
  "title": "Stepper",
  "description": "Horizontal or vertical stepper where the connecting line fills between steps, numbers morph into drawn checkmarks, a current-step ring glides to the active step, errors shake, and completed steps are clickable.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/navigation/stepper.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimatePresence, motion, useReducedMotion, type Transition } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { spring, ease as easing } from \"@/lib/goodui-motion\"\n\nexport type StepperStep = {\n  title: React.ReactNode\n  /** Second line under the title; hidden below the sm breakpoint in the horizontal layout. */\n  description?: React.ReactNode\n  /** Shown in the circle instead of the step number while the step is not complete. */\n  icon?: React.ComponentType<{ className?: string }>\n  /** Marks the step as failed: red circle, alert mark and a short shake. */\n  error?: boolean\n  /** Vertical stepper only: content that opens under the current step. */\n  content?: React.ReactNode\n}\n\nexport type StepperProps = Omit<React.ComponentProps<\"ol\">, \"defaultValue\" | \"onChange\"> & {\n  /** The steps, in order. */\n  steps: StepperStep[]\n  /** Index of the current step. Use `steps.length` to show every step as complete. */\n  value?: number\n  /** Starting step when uncontrolled. */\n  defaultValue?: number\n  /** Called with the step index when a clickable step is clicked. */\n  onValueChange?: (index: number) => void\n  /** horizontal: steps in a row with titles under the circles. vertical: a column that can open content under the current step. */\n  orientation?: \"horizontal\" | \"vertical\"\n  /** Which steps can be clicked to jump to them. */\n  clickable?: \"completed\" | \"all\" | \"none\"\n  /** Text for built-in controls and screen readers; pass translations here. */\n  labels?: Partial<StepperLabels>\n}\n\ntype Status = \"complete\" | \"current\" | \"upcoming\" | \"error\"\n\nfunction useControllable<T>(value: T | undefined, defaultValue: T, onChange?: (v: T) => void) {\n  const [inner, setInner] = React.useState(defaultValue)\n  const controlled = value !== undefined\n  const current = controlled ? value : inner\n  const set = React.useCallback(\n    (next: T) => {\n      if (!controlled) setInner(next)\n      onChange?.(next)\n    },\n    [controlled, onChange],\n  )\n  return [current, set] as const\n}\n\n/** Screen-reader status read after each step title. */\nexport type StepperLabels = { complete: string; current: string; upcoming: string; error: string }\nconst DEFAULT_LABELS: StepperLabels = {\n  complete: \"completed\",\n  current: \"current step\",\n  upcoming: \"not started\",\n  error: \"needs attention\",\n}\n\nconst CIRCLE: Record<Status, string> = {\n  complete: \"border-primary bg-primary text-primary-foreground\",\n  current: \"border-primary bg-background text-primary\",\n  upcoming: \"border-border bg-background text-muted-foreground\",\n  error: \"border-destructive bg-destructive text-white dark:text-background\",\n}\n\nfunction Indicator({ status, index, icon: Icon, uid, reduce }: { status: Status; index: number; icon?: StepperStep[\"icon\"]; uid: string; reduce: boolean }) {\n  const swap: Transition = reduce ? { duration: 0 } : spring.ui\n  const pop = reduce\n    ? { scale: 1, x: 0 }\n    : status === \"complete\"\n      ? { scale: [1, 1.14, 1], x: 0 }\n      : status === \"error\"\n        ? { scale: 1, x: [0, -5, 5, -3, 3, 0] }\n        : { scale: 1, x: 0 }\n  return (\n    <motion.span\n      aria-hidden=\"true\"\n      className={cn(\n        \"relative z-10 flex size-8 shrink-0 items-center justify-center rounded-full border-2 text-sm font-semibold tabular-nums transition-colors duration-300\",\n        CIRCLE[status],\n      )}\n      initial={false}\n      animate={pop}\n      transition={{ duration: 0.4, ease: \"easeOut\" }}\n    >\n      {status === \"current\" && (\n        <motion.span\n          layoutId={`${uid}-ring`}\n          className=\"absolute -inset-[5px] rounded-full border-2 border-primary/25\"\n          transition={reduce ? { duration: 0 } : spring.morph}\n        />\n      )}\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        {status === \"complete\" ? (\n          <motion.svg\n            key=\"check\"\n            viewBox=\"0 0 24 24\"\n            className=\"size-4\"\n            fill=\"none\"\n            stroke=\"currentColor\"\n            strokeWidth={3}\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n            initial={{ opacity: 0, scale: 0.6 }}\n            animate={{ opacity: 1, scale: 1 }}\n            exit={{ opacity: 0, scale: 0.6 }}\n            transition={swap}\n          >\n            <motion.path\n              d=\"M5 12.5l4.5 4.5L19 7.5\"\n              initial={{ pathLength: reduce ? 1 : 0 }}\n              animate={{ pathLength: 1 }}\n              transition={reduce ? { duration: 0 } : { duration: 0.3, delay: 0.08, ease: \"easeOut\" }}\n            />\n          </motion.svg>\n        ) : status === \"error\" ? (\n          <motion.span key=\"error\" initial={{ opacity: 0, scale: 0.4 }} animate={{ opacity: 1, scale: 1 }} exit={{ opacity: 0, scale: 0.4 }} transition={swap}>\n            !\n          </motion.span>\n        ) : (\n          <motion.span key=\"num\" initial={{ opacity: 0, scale: 0.6 }} animate={{ opacity: 1, scale: 1 }} exit={{ opacity: 0, scale: 0.6 }} transition={swap}>\n            {Icon ? <Icon className=\"size-4\" /> : index + 1}\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </motion.span>\n  )\n}\n\n/**\n * Stepper with a connecting line that fills between steps, numbers that morph into checkmarks, an error state,\n * clickable completed steps, and a horizontal or vertical layout (vertical can open content under the current step).\n */\nexport function Stepper({\n  steps,\n  value,\n  defaultValue = 0,\n  onValueChange,\n  orientation = \"horizontal\",\n  clickable = \"completed\",\n  labels,\n  className,\n  ...props\n}: StepperProps) {\n  const l = useLabels(\"stepper\", DEFAULT_LABELS, labels)\n  const uid = React.useId()\n  const reduce = useReducedMotion() ?? false\n  const [current, setCurrent] = useControllable(value, defaultValue, onValueChange)\n  const vertical = orientation === \"vertical\"\n  const fill: Transition = reduce ? { duration: 0 } : { duration: 0.45, ease: easing.drawer }\n\n  const statusOf = (i: number): Status => (steps[i]?.error ? \"error\" : i < current ? \"complete\" : i === current ? \"current\" : \"upcoming\")\n\n  return (\n    <ol\n      data-slot=\"stepper\"\n      data-orientation={orientation}\n      className={cn(vertical ? \"flex flex-col\" : \"flex w-full items-start\", className)}\n      {...props}\n    >\n      {steps.map((step, i) => {\n        const status = statusOf(i)\n        const canClick = clickable === \"all\" ? i !== current : clickable === \"completed\" ? i < current && i !== current : false\n        const last = i === steps.length - 1\n        const filled = i < current\n        const Head = canClick ? \"button\" : \"div\"\n        const headProps = canClick ? { type: \"button\" as const, onClick: () => setCurrent(i) } : {}\n\n        const text = (\n          <span className={cn(\"flex min-w-0 flex-col\", vertical ? \"pt-1 text-start\" : \"mt-2 items-center px-1 text-center\")}>\n            <span\n              className={cn(\n                \"text-xs leading-snug font-medium transition-colors sm:text-sm\",\n                status === \"upcoming\" ? \"text-muted-foreground\" : status === \"error\" ? \"text-destructive\" : \"text-foreground\",\n              )}\n            >\n              {step.title}\n            </span>\n            {step.description && (\n              <span className={cn(\"text-xs text-muted-foreground\", !vertical && \"hidden sm:block\")}>{step.description}</span>\n            )}\n            <span className=\"sr-only\">, {l[status]}</span>\n          </span>\n        )\n\n        if (vertical) {\n          return (\n            <li key={i} aria-current={status === \"current\" ? \"step\" : undefined} className={cn(\"relative flex gap-3\", !last && \"pb-6\")}>\n              {!last && (\n                <span aria-hidden=\"true\" className=\"absolute top-10 bottom-1.5 start-4 w-0.5 -translate-x-1/2 overflow-hidden rounded-full bg-border rtl:translate-x-1/2\">\n                  <motion.span className=\"absolute inset-0 origin-top bg-primary\" initial={false} animate={{ scaleY: filled ? 1 : 0 }} transition={fill} />\n                </span>\n              )}\n              <div className=\"flex min-w-0 flex-1 flex-col\">\n                <Head\n                  {...headProps}\n                  className={cn(\n                    \"-m-1 flex items-start gap-3 rounded-lg p-1 text-start outline-none\",\n                    canClick && \"cursor-pointer transition-colors hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50\",\n                  )}\n                >\n                  <Indicator status={status} index={i} icon={step.icon} uid={uid} reduce={reduce} />\n                  {text}\n                </Head>\n                <AnimatePresence initial={false}>\n                  {step.content && i === current && (\n                    <motion.div\n                      key=\"content\"\n                      initial={{ height: 0, opacity: 0 }}\n                      animate={{ height: \"auto\", opacity: 1 }}\n                      exit={{ height: 0, opacity: 0 }}\n                      transition={reduce ? { duration: 0 } : { type: \"spring\", bounce: 0, duration: 0.4 }}\n                      className=\"-mx-1 overflow-hidden px-1 ps-12\"\n                    >\n                      <div className=\"pt-2 pb-1\">{step.content}</div>\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </div>\n            </li>\n          )\n        }\n\n        return (\n          <li key={i} aria-current={status === \"current\" ? \"step\" : undefined} className=\"relative flex min-w-0 flex-1 flex-col items-center\">\n            {!last && (\n              <span\n                aria-hidden=\"true\"\n                className=\"absolute top-[15px] start-[calc(50%+1.5rem)] end-[calc(-50%+1.5rem)] h-0.5 overflow-hidden rounded-full bg-border\"\n              >\n                <motion.span className=\"absolute inset-0 origin-left bg-primary rtl:origin-right\" initial={false} animate={{ scaleX: filled ? 1 : 0 }} transition={fill} />\n              </span>\n            )}\n            <Head\n              {...headProps}\n              className={cn(\n                \"flex max-w-full flex-col items-center rounded-lg p-1 outline-none -mt-1\",\n                canClick && \"group cursor-pointer focus-visible:ring-3 focus-visible:ring-ring/50\",\n              )}\n            >\n              <span className={cn(\"rounded-full transition-transform\", canClick && \"group-hover:scale-105\")}>\n                <Indicator status={status} index={i} icon={step.icon} uid={uid} reduce={reduce} />\n              </span>\n              {text}\n            </Head>\n          </li>\n        )\n      })}\n    </ol>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/stepper.tsx"
    }
  ],
  "categories": [
    "components",
    "navigation"
  ],
  "type": "registry:component"
}