{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"react-stepper-collection-with-horizontal-vertical-progress-steppers-and-a-validated-multi-step-form","type":"registry:block","title":"React Stepper and Multi-Step Form Components","description":"Free React steppers in Tailwind: horizontal, vertical, progress bar, chevron and dots, plus a multi-step form with per-step validation and saved progress.","dependencies":[],"files":[{"path":"components/we-inc/react-stepper-collection-with-horizontal-vertical-progress-steppers-and-a-validated-multi-step-form.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { FormEvent } from \"react\";\n\n/*\n  React stepper collection.\n  Each piece is a live component and, beside it, the exact source you copy. Steppers are an\n  ordered list with aria-current=\"step\" on the active item; the multi-step form validates one\n  step at a time and saves its draft in the browser so a refresh does not lose it.\n*/\n\ntype Fam = \"steppers\" | \"form\";\ntype Lang = \"react\" | \"html\";\ntype Item = { f: Fam; name: string; note: string; Demo: () => JSX.Element; code: Partial<Record<Lang, string>>; wide?: boolean };\n\nconst FAMILIES: Record<Fam, string> = { steppers: \"Steppers\", form: \"Multi-step form\" };\nconst LANGS: Record<Lang, string> = { react: \"React + Tailwind\", html: \"HTML + Tailwind\" };\n\nconst CHECK = \"M5 12.5l4.5 4.5L19 7.5\";\n\n/* ---------- 1. Horizontal numbered ---------- */\nconst H_STEPS = [\"Cart\", \"Shipping\", \"Payment\", \"Review\"];\n\nfunction HorizontalStepper() {\n  const [step, setStep] = useState(1);\n  const last = H_STEPS.length - 1;\n  return (\n    <div>\n      <p className=\"text-sm text-slate-600 sm:hidden\">\n        Step {step + 1} of {H_STEPS.length}: <span className=\"font-semibold text-slate-900\">{H_STEPS[step]}</span>\n      </p>\n      <ol aria-label=\"Checkout progress\" className=\"mt-2 flex items-center sm:mt-0\">\n        {H_STEPS.map((label, i) => {\n          const done = i < step;\n          const current = i === step;\n          return (\n            <li key={label} aria-current={current ? \"step\" : undefined} className=\"flex flex-1 items-center last:flex-none\">\n              <button\n                type=\"button\"\n                disabled={!done}\n                onClick={() => setStep(i)}\n                className=\"flex min-h-[40px] items-center gap-2 rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2 disabled:cursor-default\"\n              >\n                <span\n                  className={\n                    \"grid h-8 w-8 shrink-0 place-items-center rounded-full text-sm font-semibold transition-colors \" +\n                    (done ? \"bg-teal-700 text-white\" : current ? \"border-2 border-teal-700 text-teal-800\" : \"border border-slate-300 text-slate-500\")\n                  }\n                >\n                  {done ? (\n                    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-4 w-4\">\n                      <path d={CHECK} />\n                    </svg>\n                  ) : (\n                    i + 1\n                  )}\n                </span>\n                <span className={\"hidden text-sm sm:inline \" + (current ? \"font-semibold text-slate-900\" : \"text-slate-600\")}>{label}</span>\n                {done && <span className=\"sr-only\">, completed</span>}\n              </button>\n              {i < last && <span aria-hidden=\"true\" className={\"mx-2 h-px flex-1 sm:mx-3 \" + (done ? \"bg-teal-700\" : \"bg-slate-300\")} />}\n            </li>\n          );\n        })}\n      </ol>\n      <div className=\"mt-5 flex justify-between gap-3\">\n        <button type=\"button\" onClick={() => setStep(Math.max(step - 1, 0))} disabled={step === 0} className=\"h-10 rounded-lg px-4 text-sm font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 disabled:opacity-40\">\n          Back\n        </button>\n        <button type=\"button\" onClick={() => setStep(Math.min(step + 1, last))} disabled={step === last} className=\"h-10 rounded-lg bg-teal-700 px-4 text-sm font-semibold text-white hover:bg-teal-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2 disabled:opacity-40\">\n          Continue\n        </button>\n      </div>\n    </div>\n  );\n}\n\nconst HORIZONTAL_REACT = `import { useState } from \"react\";\n\nconst H_STEPS = [\"Cart\", \"Shipping\", \"Payment\", \"Review\"];\nconst CHECK = \"M5 12.5l4.5 4.5L19 7.5\";\n\n// Completed steps are buttons you can return to; future steps stay disabled.\n// Below 640px the labels hide and a \"Step 2 of 4\" line takes their place.\nexport function HorizontalStepper() {\n  const [step, setStep] = useState(1);\n  const last = H_STEPS.length - 1;\n  return (\n    <div>\n      <p className=\"text-sm text-slate-600 sm:hidden\">\n        Step {step + 1} of {H_STEPS.length}: <span className=\"font-semibold text-slate-900\">{H_STEPS[step]}</span>\n      </p>\n      <ol aria-label=\"Checkout progress\" className=\"mt-2 flex items-center sm:mt-0\">\n        {H_STEPS.map((label, i) => {\n          const done = i < step;\n          const current = i === step;\n          return (\n            <li key={label} aria-current={current ? \"step\" : undefined} className=\"flex flex-1 items-center last:flex-none\">\n              <button\n                type=\"button\"\n                disabled={!done}\n                onClick={() => setStep(i)}\n                className=\"flex min-h-[40px] items-center gap-2 rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2 disabled:cursor-default\"\n              >\n                <span\n                  className={\n                    \"grid h-8 w-8 shrink-0 place-items-center rounded-full text-sm font-semibold transition-colors \" +\n                    (done ? \"bg-teal-700 text-white\" : current ? \"border-2 border-teal-700 text-teal-800\" : \"border border-slate-300 text-slate-500\")\n                  }\n                >\n                  {done ? (\n                    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-4 w-4\">\n                      <path d={CHECK} />\n                    </svg>\n                  ) : (\n                    i + 1\n                  )}\n                </span>\n                <span className={\"hidden text-sm sm:inline \" + (current ? \"font-semibold text-slate-900\" : \"text-slate-600\")}>{label}</span>\n                {done && <span className=\"sr-only\">, completed</span>}\n              </button>\n              {i < last && <span aria-hidden=\"true\" className={\"mx-2 h-px flex-1 sm:mx-3 \" + (done ? \"bg-teal-700\" : \"bg-slate-300\")} />}\n            </li>\n          );\n        })}\n      </ol>\n      <div className=\"mt-5 flex justify-between gap-3\">\n        <button type=\"button\" onClick={() => setStep(Math.max(step - 1, 0))} disabled={step === 0} className=\"h-10 rounded-lg px-4 text-sm font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 disabled:opacity-40\">\n          Back\n        </button>\n        <button type=\"button\" onClick={() => setStep(Math.min(step + 1, last))} disabled={step === last} className=\"h-10 rounded-lg bg-teal-700 px-4 text-sm font-semibold text-white hover:bg-teal-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2 disabled:opacity-40\">\n          Continue\n        </button>\n      </div>\n    </div>\n  );\n}`;\n\nconst HORIZONTAL_HTML = `<!-- Static snapshot: step 2 of 4. Move aria-current=\"step\" and the classes as the user advances. -->\n<ol aria-label=\"Checkout progress\" class=\"flex items-center\">\n  <li class=\"flex flex-1 items-center\">\n    <span class=\"flex min-h-[40px] items-center gap-2\">\n      <span class=\"grid h-8 w-8 shrink-0 place-items-center rounded-full bg-teal-700 text-sm font-semibold text-white\">\n        <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"h-4 w-4\"><path d=\"M5 12.5l4.5 4.5L19 7.5\"/></svg>\n      </span>\n      <span class=\"hidden text-sm text-slate-600 sm:inline\">Cart</span><span class=\"sr-only\">, completed</span>\n    </span>\n    <span aria-hidden=\"true\" class=\"mx-2 h-px flex-1 bg-teal-700 sm:mx-3\"></span>\n  </li>\n  <li aria-current=\"step\" class=\"flex flex-1 items-center\">\n    <span class=\"flex min-h-[40px] items-center gap-2\">\n      <span class=\"grid h-8 w-8 shrink-0 place-items-center rounded-full border-2 border-teal-700 text-sm font-semibold text-teal-800\">2</span>\n      <span class=\"hidden text-sm font-semibold text-slate-900 sm:inline\">Shipping</span>\n    </span>\n    <span aria-hidden=\"true\" class=\"mx-2 h-px flex-1 bg-slate-300 sm:mx-3\"></span>\n  </li>\n  <li class=\"flex flex-1 items-center\">\n    <span class=\"flex min-h-[40px] items-center gap-2\">\n      <span class=\"grid h-8 w-8 shrink-0 place-items-center rounded-full border border-slate-300 text-sm font-semibold text-slate-500\">3</span>\n      <span class=\"hidden text-sm text-slate-600 sm:inline\">Payment</span>\n    </span>\n    <span aria-hidden=\"true\" class=\"mx-2 h-px flex-1 bg-slate-300 sm:mx-3\"></span>\n  </li>\n  <li class=\"flex items-center\">\n    <span class=\"flex min-h-[40px] items-center gap-2\">\n      <span class=\"grid h-8 w-8 shrink-0 place-items-center rounded-full border border-slate-300 text-sm font-semibold text-slate-500\">4</span>\n      <span class=\"hidden text-sm text-slate-600 sm:inline\">Review</span>\n    </span>\n  </li>\n</ol>`;\n\n/* ---------- 2. Vertical with descriptions ---------- */\nconst V_STEPS = [\n  { title: \"Connect your domain\", body: \"Point the A record at the address in Settings. Changes can take a few hours to spread.\" },\n  { title: \"Add your opening hours\", body: \"Hours appear in the footer and on the contact page, and update both at once.\" },\n  { title: \"Upload a logo\", body: \"A square SVG or PNG of at least 512px looks sharp in the header and browser tab.\" },\n  { title: \"Publish\", body: \"Your site goes live at your domain. You can keep editing afterwards.\" },\n];\n\nfunction VerticalStepper() {\n  const [step, setStep] = useState(1);\n  return (\n    <ol aria-label=\"Site setup\" className=\"relative\">\n      {V_STEPS.map((s, i) => {\n        const done = i < step;\n        const current = i === step;\n        return (\n          <li key={s.title} aria-current={current ? \"step\" : undefined} className=\"relative flex gap-4 pb-6 last:pb-0\">\n            {i < V_STEPS.length - 1 && <span aria-hidden=\"true\" className={\"absolute left-[15px] top-9 h-[calc(100%-2.5rem)] w-px \" + (done ? \"bg-slate-900\" : \"bg-slate-200\")} />}\n            <span className={\"relative grid h-8 w-8 shrink-0 place-items-center rounded-full text-xs font-semibold \" + (done ? \"bg-slate-900 text-white\" : current ? \"bg-white text-slate-900 ring-2 ring-slate-900\" : \"bg-white text-slate-500 ring-1 ring-slate-300\")}>\n              {done ? (\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-4 w-4\">\n                  <path d={CHECK} />\n                </svg>\n              ) : (\n                i + 1\n              )}\n            </span>\n            <div className=\"min-w-0 pt-1\">\n              <p className={\"text-sm \" + (current ? \"font-semibold text-slate-900\" : done ? \"text-slate-700\" : \"text-slate-600\")}>\n                {s.title}\n                {done && <span className=\"sr-only\"> (done)</span>}\n              </p>\n              {current && (\n                <div className=\"mt-1.5\">\n                  <p className=\"text-sm leading-relaxed text-slate-600\">{s.body}</p>\n                  <div className=\"mt-3 flex gap-2\">\n                    <button type=\"button\" onClick={() => setStep(i + 1)} className=\"h-10 rounded-md bg-slate-900 px-3.5 text-sm font-semibold text-white hover:bg-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-900 focus-visible:ring-offset-2\">\n                      {i === V_STEPS.length - 1 ? \"Publish site\" : \"Mark as done\"}\n                    </button>\n                    {i > 0 && (\n                      <button type=\"button\" onClick={() => setStep(i - 1)} className=\"h-10 rounded-md px-3 text-sm font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-900\">\n                        Back\n                      </button>\n                    )}\n                  </div>\n                </div>\n              )}\n            </div>\n          </li>\n        );\n      })}\n      {step >= V_STEPS.length && (\n        <li className=\"mt-4 rounded-md bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-900\" role=\"status\">\n          All four steps are done. The site is live.\n        </li>\n      )}\n    </ol>\n  );\n}\n\nconst VERTICAL_REACT = `import { useState } from \"react\";\n\nconst CHECK = \"M5 12.5l4.5 4.5L19 7.5\";\nconst V_STEPS = [\n  { title: \"Connect your domain\", body: \"Point the A record at the address in Settings. Changes can take a few hours to spread.\" },\n  { title: \"Add your opening hours\", body: \"Hours appear in the footer and on the contact page, and update both at once.\" },\n  { title: \"Upload a logo\", body: \"A square SVG or PNG of at least 512px looks sharp in the header and browser tab.\" },\n  { title: \"Publish\", body: \"Your site goes live at your domain. You can keep editing afterwards.\" },\n];\n\n// Only the current step shows its description and actions, which keeps a long\n// checklist short on a phone. The connecting line darkens as steps complete.\nexport function VerticalStepper() {\n  const [step, setStep] = useState(1);\n  return (\n    <ol aria-label=\"Site setup\" className=\"relative\">\n      {V_STEPS.map((s, i) => {\n        const done = i < step;\n        const current = i === step;\n        return (\n          <li key={s.title} aria-current={current ? \"step\" : undefined} className=\"relative flex gap-4 pb-6 last:pb-0\">\n            {i < V_STEPS.length - 1 && <span aria-hidden=\"true\" className={\"absolute left-[15px] top-9 h-[calc(100%-2.5rem)] w-px \" + (done ? \"bg-slate-900\" : \"bg-slate-200\")} />}\n            <span className={\"relative grid h-8 w-8 shrink-0 place-items-center rounded-full text-xs font-semibold \" + (done ? \"bg-slate-900 text-white\" : current ? \"bg-white text-slate-900 ring-2 ring-slate-900\" : \"bg-white text-slate-500 ring-1 ring-slate-300\")}>\n              {done ? (\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-4 w-4\">\n                  <path d={CHECK} />\n                </svg>\n              ) : (\n                i + 1\n              )}\n            </span>\n            <div className=\"min-w-0 pt-1\">\n              <p className={\"text-sm \" + (current ? \"font-semibold text-slate-900\" : done ? \"text-slate-700\" : \"text-slate-600\")}>\n                {s.title}\n                {done && <span className=\"sr-only\"> (done)</span>}\n              </p>\n              {current && (\n                <div className=\"mt-1.5\">\n                  <p className=\"text-sm leading-relaxed text-slate-600\">{s.body}</p>\n                  <div className=\"mt-3 flex gap-2\">\n                    <button type=\"button\" onClick={() => setStep(i + 1)} className=\"h-10 rounded-md bg-slate-900 px-3.5 text-sm font-semibold text-white hover:bg-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-900 focus-visible:ring-offset-2\">\n                      {i === V_STEPS.length - 1 ? \"Publish site\" : \"Mark as done\"}\n                    </button>\n                    {i > 0 && (\n                      <button type=\"button\" onClick={() => setStep(i - 1)} className=\"h-10 rounded-md px-3 text-sm font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-900\">\n                        Back\n                      </button>\n                    )}\n                  </div>\n                </div>\n              )}\n            </div>\n          </li>\n        );\n      })}\n      {step >= V_STEPS.length && (\n        <li className=\"mt-4 rounded-md bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-900\" role=\"status\">\n          All four steps are done. The site is live.\n        </li>\n      )}\n    </ol>\n  );\n}`;\n\n/* ---------- 3. Segmented progress bar ---------- */\nconst P_STEPS = [\"Brief\", \"Moodboard\", \"First draft\", \"Revisions\", \"Handover\"];\n\nfunction ProgressStepper() {\n  const [step, setStep] = useState(2);\n  const pct = Math.round((step / (P_STEPS.length - 1)) * 100);\n  return (\n    <div className=\"rounded-xl bg-[#0f172a] p-5 text-slate-200\">\n      <div className=\"flex items-baseline justify-between gap-3\">\n        <p className=\"text-sm\">\n          <span className=\"text-slate-400\">Stage {step + 1} of {P_STEPS.length}</span>\n          <span className=\"ml-2 font-semibold text-white\">{P_STEPS[step]}</span>\n        </p>\n        <p className=\"font-mono text-xs tabular-nums text-amber-300\">{pct}%</p>\n      </div>\n      <div role=\"progressbar\" aria-label=\"Project progress\" aria-valuemin={0} aria-valuemax={100} aria-valuenow={pct} aria-valuetext={`${P_STEPS[step]}, stage ${step + 1} of ${P_STEPS.length}`} className=\"mt-3 flex gap-1.5\">\n        {P_STEPS.map((s, i) => (\n          <span key={s} className=\"h-1.5 flex-1 overflow-hidden rounded-full bg-slate-700\">\n            <span className={\"block h-full origin-left rounded-full bg-amber-300 transition-transform duration-500 motion-reduce:transition-none \" + (i <= step ? \"scale-x-100\" : \"scale-x-0\")} />\n          </span>\n        ))}\n      </div>\n      <ol className=\"mt-2 hidden grid-cols-5 gap-1.5 text-[11px] text-slate-400 sm:grid\" aria-hidden=\"true\">\n        {P_STEPS.map((s, i) => (\n          <li key={s} className={i === step ? \"text-slate-100\" : \"\"}>{s}</li>\n        ))}\n      </ol>\n      <div className=\"mt-4 flex gap-2\">\n        <button type=\"button\" onClick={() => setStep(Math.max(step - 1, 0))} disabled={step === 0} className=\"h-10 rounded-md border border-slate-600 px-3 text-sm text-slate-100 hover:bg-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300 disabled:opacity-40\">\n          Previous stage\n        </button>\n        <button type=\"button\" onClick={() => setStep(Math.min(step + 1, P_STEPS.length - 1))} disabled={step === P_STEPS.length - 1} className=\"h-10 rounded-md bg-amber-300 px-3 text-sm font-semibold text-slate-900 hover:bg-amber-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300 focus-visible:ring-offset-2 focus-visible:ring-offset-[#0f172a] disabled:opacity-40\">\n          Next stage\n        </button>\n      </div>\n    </div>\n  );\n}\n\nconst PROGRESS_REACT = `import { useState } from \"react\";\n\nconst P_STEPS = [\"Brief\", \"Moodboard\", \"First draft\", \"Revisions\", \"Handover\"];\n\n// One progressbar element carries the meaning; the five segments are visual only.\n// aria-valuetext tells screen readers the stage name, not just a percentage.\nexport function ProgressStepper() {\n  const [step, setStep] = useState(2);\n  const pct = Math.round((step / (P_STEPS.length - 1)) * 100);\n  return (\n    <div className=\"rounded-xl bg-[#0f172a] p-5 text-slate-200\">\n      <div className=\"flex items-baseline justify-between gap-3\">\n        <p className=\"text-sm\">\n          <span className=\"text-slate-400\">Stage {step + 1} of {P_STEPS.length}</span>\n          <span className=\"ml-2 font-semibold text-white\">{P_STEPS[step]}</span>\n        </p>\n        <p className=\"font-mono text-xs tabular-nums text-amber-300\">{pct}%</p>\n      </div>\n      <div role=\"progressbar\" aria-label=\"Project progress\" aria-valuemin={0} aria-valuemax={100} aria-valuenow={pct} aria-valuetext={P_STEPS[step] + \", stage \" + (step + 1) + \" of \" + P_STEPS.length} className=\"mt-3 flex gap-1.5\">\n        {P_STEPS.map((s, i) => (\n          <span key={s} className=\"h-1.5 flex-1 overflow-hidden rounded-full bg-slate-700\">\n            <span className={\"block h-full origin-left rounded-full bg-amber-300 transition-transform duration-500 motion-reduce:transition-none \" + (i <= step ? \"scale-x-100\" : \"scale-x-0\")} />\n          </span>\n        ))}\n      </div>\n      <ol className=\"mt-2 hidden grid-cols-5 gap-1.5 text-[11px] text-slate-400 sm:grid\" aria-hidden=\"true\">\n        {P_STEPS.map((s, i) => (\n          <li key={s} className={i === step ? \"text-slate-100\" : \"\"}>{s}</li>\n        ))}\n      </ol>\n      <div className=\"mt-4 flex gap-2\">\n        <button type=\"button\" onClick={() => setStep(Math.max(step - 1, 0))} disabled={step === 0} className=\"h-10 rounded-md border border-slate-600 px-3 text-sm text-slate-100 hover:bg-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300 disabled:opacity-40\">\n          Previous stage\n        </button>\n        <button type=\"button\" onClick={() => setStep(Math.min(step + 1, P_STEPS.length - 1))} disabled={step === P_STEPS.length - 1} className=\"h-10 rounded-md bg-amber-300 px-3 text-sm font-semibold text-slate-900 hover:bg-amber-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300 focus-visible:ring-offset-2 focus-visible:ring-offset-[#0f172a] disabled:opacity-40\">\n          Next stage\n        </button>\n      </div>\n    </div>\n  );\n}`;\n\n/* ---------- 4. Chevron breadcrumb stepper ---------- */\nconst C_STEPS = [\"Details\", \"Delivery\", \"Payment\"];\n\nfunction ChevronStepper() {\n  const [step, setStep] = useState(1);\n  return (\n    <div>\n      <ol aria-label=\"Order steps\" className=\"flex overflow-hidden rounded-lg border border-indigo-200\">\n        {C_STEPS.map((s, i) => {\n          const current = i === step;\n          const done = i < step;\n          return (\n            <li key={s} aria-current={current ? \"step\" : undefined} className=\"relative flex-1\">\n              <button\n                type=\"button\"\n                onClick={() => setStep(i)}\n                className={\n                  \"flex h-12 w-full items-center justify-center gap-1.5 pl-3 pr-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-700 \" +\n                  (current ? \"bg-indigo-700 font-semibold text-white\" : done ? \"bg-indigo-50 text-indigo-900\" : \"bg-white text-slate-600\")\n                }\n              >\n                <span className=\"font-mono text-xs opacity-80\">{i + 1}</span>\n                {s}\n              </button>\n              {i < C_STEPS.length - 1 && (\n                <svg viewBox=\"0 0 12 48\" preserveAspectRatio=\"none\" aria-hidden=\"true\" className=\"pointer-events-none absolute -right-[6px] top-0 z-10 h-12 w-3\">\n                  <path d=\"M0 0 L12 24 L0 48\" fill={current ? \"#4338ca\" : done ? \"#eef2ff\" : \"#ffffff\"} stroke=\"#c7d2fe\" strokeWidth={1} />\n                </svg>\n              )}\n            </li>\n          );\n        })}\n      </ol>\n      <p className=\"mt-3 text-sm text-slate-600\">Any step can be opened directly; useful when the order is a suggestion, not a rule.</p>\n    </div>\n  );\n}\n\nconst CHEVRON_REACT = `import { useState } from \"react\";\n\nconst C_STEPS = [\"Details\", \"Delivery\", \"Payment\"];\n\n// Arrow-shaped segments for checkouts where any step may be revisited.\n// The arrow tip is a small SVG so the borders stay crisp at any zoom.\nexport function ChevronStepper() {\n  const [step, setStep] = useState(1);\n  return (\n    <div>\n      <ol aria-label=\"Order steps\" className=\"flex overflow-hidden rounded-lg border border-indigo-200\">\n        {C_STEPS.map((s, i) => {\n          const current = i === step;\n          const done = i < step;\n          return (\n            <li key={s} aria-current={current ? \"step\" : undefined} className=\"relative flex-1\">\n              <button\n                type=\"button\"\n                onClick={() => setStep(i)}\n                className={\n                  \"flex h-12 w-full items-center justify-center gap-1.5 pl-3 pr-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-700 \" +\n                  (current ? \"bg-indigo-700 font-semibold text-white\" : done ? \"bg-indigo-50 text-indigo-900\" : \"bg-white text-slate-600\")\n                }\n              >\n                <span className=\"font-mono text-xs opacity-80\">{i + 1}</span>\n                {s}\n              </button>\n              {i < C_STEPS.length - 1 && (\n                <svg viewBox=\"0 0 12 48\" preserveAspectRatio=\"none\" aria-hidden=\"true\" className=\"pointer-events-none absolute -right-[6px] top-0 z-10 h-12 w-3\">\n                  <path d=\"M0 0 L12 24 L0 48\" fill={current ? \"#4338ca\" : done ? \"#eef2ff\" : \"#ffffff\"} stroke=\"#c7d2fe\" strokeWidth={1} />\n                </svg>\n              )}\n            </li>\n          );\n        })}\n      </ol>\n      <p className=\"mt-3 text-sm text-slate-600\">Any step can be opened directly; useful when the order is a suggestion, not a rule.</p>\n    </div>\n  );\n}`;\n\n/* ---------- 5. Dot stepper for onboarding ---------- */\nconst SLIDES = [\n  { h: \"Pick a starting layout\", p: \"Choose from a page that already has your trade's sections in place.\" },\n  { h: \"Swap in your own words\", p: \"Click any heading to edit it. Your changes save as you type.\" },\n  { h: \"Add your photos\", p: \"Drop images onto any picture. They are resized for phones automatically.\" },\n  { h: \"Go live\", p: \"Connect your domain when you are ready. Nothing is public before that.\" },\n];\n\nfunction DotStepper() {\n  const [i, setI] = useState(0);\n  const last = SLIDES.length - 1;\n  return (\n    <div className=\"rounded-2xl border border-rose-100 bg-rose-50/60 p-5\">\n      <div aria-live=\"polite\">\n        <p className=\"font-mono text-[11px] uppercase tracking-[0.14em] text-rose-800\">Tip {i + 1} of {SLIDES.length}</p>\n        <h4 className=\"mt-1.5 text-base font-semibold text-slate-900\">{SLIDES[i].h}</h4>\n        <p className=\"mt-1 text-sm leading-relaxed text-slate-700\">{SLIDES[i].p}</p>\n      </div>\n      <div className=\"mt-4 flex items-center justify-between gap-3\">\n        <ol aria-label=\"Tips\" className=\"flex items-center\">\n          {SLIDES.map((s, k) => (\n            <li key={s.h}>\n              <button type=\"button\" onClick={() => setI(k)} aria-label={\"Tip \" + (k + 1) + \": \" + s.h} aria-current={k === i ? \"step\" : undefined} className=\"grid h-10 w-7 place-items-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-700\">\n                <span className={\"block h-2 rounded-full transition-all duration-300 motion-reduce:transition-none \" + (k === i ? \"w-5 bg-rose-700\" : \"w-2 bg-rose-300\")} />\n              </button>\n            </li>\n          ))}\n        </ol>\n        <button type=\"button\" onClick={() => setI(i === last ? 0 : i + 1)} className=\"h-10 rounded-full bg-rose-700 px-4 text-sm font-semibold text-white hover:bg-rose-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-700 focus-visible:ring-offset-2\">\n          {i === last ? \"Start again\" : \"Next tip\"}\n        </button>\n      </div>\n    </div>\n  );\n}\n\nconst DOT_REACT = `import { useState } from \"react\";\n\nconst SLIDES = [\n  { h: \"Pick a starting layout\", p: \"Choose from a page that already has your trade's sections in place.\" },\n  { h: \"Swap in your own words\", p: \"Click any heading to edit it. Your changes save as you type.\" },\n  { h: \"Add your photos\", p: \"Drop images onto any picture. They are resized for phones automatically.\" },\n  { h: \"Go live\", p: \"Connect your domain when you are ready. Nothing is public before that.\" },\n];\n\n// Each dot is a 40px tall button with a full label, even though it draws an 8px dot.\nexport function DotStepper() {\n  const [i, setI] = useState(0);\n  const last = SLIDES.length - 1;\n  return (\n    <div className=\"rounded-2xl border border-rose-100 bg-rose-50/60 p-5\">\n      <div aria-live=\"polite\">\n        <p className=\"font-mono text-[11px] uppercase tracking-[0.14em] text-rose-800\">Tip {i + 1} of {SLIDES.length}</p>\n        <h4 className=\"mt-1.5 text-base font-semibold text-slate-900\">{SLIDES[i].h}</h4>\n        <p className=\"mt-1 text-sm leading-relaxed text-slate-700\">{SLIDES[i].p}</p>\n      </div>\n      <div className=\"mt-4 flex items-center justify-between gap-3\">\n        <ol aria-label=\"Tips\" className=\"flex items-center\">\n          {SLIDES.map((s, k) => (\n            <li key={s.h}>\n              <button type=\"button\" onClick={() => setI(k)} aria-label={\"Tip \" + (k + 1) + \": \" + s.h} aria-current={k === i ? \"step\" : undefined} className=\"grid h-10 w-7 place-items-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-700\">\n                <span className={\"block h-2 rounded-full transition-all duration-300 motion-reduce:transition-none \" + (k === i ? \"w-5 bg-rose-700\" : \"w-2 bg-rose-300\")} />\n              </button>\n            </li>\n          ))}\n        </ol>\n        <button type=\"button\" onClick={() => setI(i === last ? 0 : i + 1)} className=\"h-10 rounded-full bg-rose-700 px-4 text-sm font-semibold text-white hover:bg-rose-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-700 focus-visible:ring-offset-2\">\n          {i === last ? \"Start again\" : \"Next tip\"}\n        </button>\n      </div>\n    </div>\n  );\n}`;\n\n/* ---------- 6. Multi-step form with validation and saved progress ---------- */\ntype Draft = { name: string; email: string; business: string; pages: string; budget: string; notes: string };\nconst EMPTY: Draft = { name: \"\", email: \"\", business: \"\", pages: \"\", budget: \"\", notes: \"\" };\nconst F_STEPS = [\"You\", \"Project\", \"Review\"];\nconst KEY = \"quote-request-draft\";\nconst store = () => {\n  try {\n    return window[\"local\" + \"Storage\"] as Storage;\n  } catch {\n    return null;\n  }\n};\n\nfunction validate(step: number, d: Draft): Partial<Record<keyof Draft, string>> {\n  const e: Partial<Record<keyof Draft, string>> = {};\n  if (step === 0) {\n    if (!d.name.trim()) e.name = \"Enter your name.\";\n    if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(d.email)) e.email = \"Enter an email like name@example.com.\";\n  }\n  if (step === 1) {\n    if (!d.business.trim()) e.business = \"Tell us the business name.\";\n    if (!d.pages) e.pages = \"Choose roughly how many pages.\";\n    if (!d.budget) e.budget = \"Pick a budget range.\";\n  }\n  return e;\n}\n\nfunction MultiStepForm() {\n  const [step, setStep] = useState(0);\n  const [d, setD] = useState<Draft>(EMPTY);\n  const [errors, setErrors] = useState<Partial<Record<keyof Draft, string>>>({});\n  const [saved, setSaved] = useState(\"\");\n  const [sent, setSent] = useState(false);\n  const heading = useRef<HTMLHeadingElement | null>(null);\n  const moved = useRef(false);\n\n  useEffect(() => {\n    try {\n      const raw = store()?.getItem(KEY);\n      if (raw) {\n        const v = JSON.parse(raw) as { step: number; d: Draft };\n        setD({ ...EMPTY, ...v.d });\n        setStep(Math.min(Math.max(v.step, 0), 2));\n        setSaved(\"Draft restored\");\n      }\n    } catch {\n      /* storage blocked or bad data: start fresh */\n    }\n  }, []);\n\n  useEffect(() => {\n    if (moved.current) heading.current?.focus();\n  }, [step]);\n\n  const save = (nextStep: number, next: Draft) => {\n    try {\n      store()?.setItem(KEY, JSON.stringify({ step: nextStep, d: next }));\n      setSaved(\"Progress saved\");\n    } catch {\n      setSaved(\"\");\n    }\n  };\n\n  const set = (k: keyof Draft, v: string) => {\n    const next = { ...d, [k]: v };\n    setD(next);\n    if (errors[k]) setErrors({ ...errors, [k]: undefined });\n    save(step, next);\n  };\n\n  const onSubmit = (ev: FormEvent<HTMLFormElement>) => {\n    ev.preventDefault();\n    const e = validate(step, d);\n    setErrors(e);\n    const first = Object.keys(e)[0];\n    if (first) {\n      ev.currentTarget.querySelector<HTMLElement>(`[name=\"${first}\"]`)?.focus();\n      return;\n    }\n    if (step < 2) {\n      moved.current = true;\n      setStep(step + 1);\n      save(step + 1, d);\n      return;\n    }\n    setSent(true);\n    try {\n      store()?.removeItem(KEY);\n    } catch {\n      /* ignore */\n    }\n  };\n\n  const back = () => {\n    moved.current = true;\n    setErrors({});\n    setStep(step - 1);\n    save(step - 1, d);\n  };\n\n  const reset = () => {\n    setD(EMPTY);\n    setStep(0);\n    setSent(false);\n    setSaved(\"\");\n    try {\n      store()?.removeItem(KEY);\n    } catch {\n      /* ignore */\n    }\n  };\n\n  const input = (bad?: string) =>\n    \"mt-1.5 block h-11 w-full rounded-lg border bg-white px-3 text-sm text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 \" + (bad ? \"border-red-600\" : \"border-slate-300\");\n  const err = (k: keyof Draft) =>\n    errors[k] ? (\n      <p id={\"msf-\" + k + \"-err\"} className=\"mt-1 text-xs font-medium text-red-700\">\n        {errors[k]}\n      </p>\n    ) : null;\n  const aria = (k: keyof Draft) => ({ \"aria-invalid\": errors[k] ? true : undefined, \"aria-describedby\": errors[k] ? \"msf-\" + k + \"-err\" : undefined });\n\n  if (sent) {\n    return (\n      <div role=\"status\" className=\"rounded-xl border border-teal-200 bg-teal-50 p-6\">\n        <h4 className=\"text-base font-semibold text-teal-950\">Request sent</h4>\n        <p className=\"mt-1 text-sm text-teal-900\">Thanks, {d.name.split(\" \")[0]}. A quote for {d.business} will reach {d.email} within two working days.</p>\n        <button type=\"button\" onClick={reset} className=\"mt-4 h-10 rounded-lg bg-teal-700 px-4 text-sm font-semibold text-white hover:bg-teal-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\">\n          Start a new request\n        </button>\n      </div>\n    );\n  }\n\n  return (\n    <form noValidate onSubmit={onSubmit} className=\"grid gap-6 md:grid-cols-[180px_1fr]\">\n      <ol aria-label=\"Quote request steps\" className=\"flex gap-4 md:flex-col md:gap-3\">\n        {F_STEPS.map((s, i) => (\n          <li key={s} aria-current={i === step ? \"step\" : undefined} className=\"flex items-center gap-2.5 text-sm\">\n            <span className={\"grid h-7 w-7 place-items-center rounded-full text-xs font-semibold \" + (i < step ? \"bg-teal-700 text-white\" : i === step ? \"ring-2 ring-teal-700 text-teal-800\" : \"ring-1 ring-slate-300 text-slate-500\")}>\n              {i < step ? (\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-3.5 w-3.5\">\n                  <path d={CHECK} />\n                </svg>\n              ) : (\n                i + 1\n              )}\n            </span>\n            <span className={i === step ? \"font-semibold text-slate-900\" : \"text-slate-600\"}>{s}</span>\n          </li>\n        ))}\n        <li className=\"ml-auto self-center text-xs text-slate-600 md:ml-0 md:mt-2\" aria-live=\"polite\">\n          {saved}\n        </li>\n      </ol>\n\n      <div className=\"min-w-0\">\n        <h4 ref={heading} tabIndex={-1} className=\"text-base font-semibold text-slate-900 focus:outline-none\">\n          {[\"About you\", \"About the project\", \"Check and send\"][step]}\n        </h4>\n\n        {step === 0 && (\n          <div className=\"mt-4 grid gap-4 sm:grid-cols-2\">\n            <div>\n              <label htmlFor=\"msf-name\" className=\"text-sm font-medium text-slate-800\">Full name</label>\n              <input id=\"msf-name\" name=\"name\" autoComplete=\"name\" value={d.name} onChange={(e) => set(\"name\", e.target.value)} className={input(errors.name)} {...aria(\"name\")} />\n              {err(\"name\")}\n            </div>\n            <div>\n              <label htmlFor=\"msf-email\" className=\"text-sm font-medium text-slate-800\">Email</label>\n              <input id=\"msf-email\" name=\"email\" type=\"email\" autoComplete=\"email\" value={d.email} onChange={(e) => set(\"email\", e.target.value)} className={input(errors.email)} {...aria(\"email\")} />\n              {err(\"email\")}\n            </div>\n          </div>\n        )}\n\n        {step === 1 && (\n          <div className=\"mt-4 grid gap-4 sm:grid-cols-2\">\n            <div className=\"sm:col-span-2\">\n              <label htmlFor=\"msf-business\" className=\"text-sm font-medium text-slate-800\">Business name</label>\n              <input id=\"msf-business\" name=\"business\" autoComplete=\"organization\" value={d.business} onChange={(e) => set(\"business\", e.target.value)} className={input(errors.business)} {...aria(\"business\")} />\n              {err(\"business\")}\n            </div>\n            <div>\n              <label htmlFor=\"msf-pages\" className=\"text-sm font-medium text-slate-800\">Number of pages</label>\n              <select id=\"msf-pages\" name=\"pages\" value={d.pages} onChange={(e) => set(\"pages\", e.target.value)} className={input(errors.pages)} {...aria(\"pages\")}>\n                <option value=\"\">Choose</option>\n                <option>1 to 3</option>\n                <option>4 to 8</option>\n                <option>9 or more</option>\n              </select>\n              {err(\"pages\")}\n            </div>\n            <fieldset aria-describedby={errors.budget ? \"msf-budget-err\" : undefined}>\n              <legend className=\"text-sm font-medium text-slate-800\">Budget</legend>\n              <div className=\"mt-1.5 flex gap-2\">\n                {[\"Under $2k\", \"$2k to $6k\", \"$6k+\"].map((b, k) => (\n                  <label key={b} htmlFor={\"msf-budget-\" + k} className={\"flex h-11 flex-1 cursor-pointer items-center justify-center rounded-lg border px-2 text-center text-xs font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-teal-600 \" + (d.budget === b ? \"border-teal-700 bg-teal-50 text-teal-900\" : errors.budget ? \"border-red-600 text-slate-700\" : \"border-slate-300 text-slate-700\")}>\n                    <input id={\"msf-budget-\" + k} type=\"radio\" name=\"budget\" value={b} checked={d.budget === b} onChange={() => set(\"budget\", b)} className=\"sr-only\" />\n                    {b}\n                  </label>\n                ))}\n              </div>\n              {err(\"budget\")}\n            </fieldset>\n            <div className=\"sm:col-span-2\">\n              <label htmlFor=\"msf-notes\" className=\"text-sm font-medium text-slate-800\">\n                Anything else <span className=\"font-normal text-slate-600\">(optional)</span>\n              </label>\n              <textarea id=\"msf-notes\" name=\"notes\" rows={2} value={d.notes} onChange={(e) => set(\"notes\", e.target.value)} className=\"mt-1.5 block w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\" />\n            </div>\n          </div>\n        )}\n\n        {step === 2 && (\n          <dl className=\"mt-4 divide-y divide-slate-200 rounded-lg border border-slate-200 text-sm\">\n            {([\n              [\"Name\", d.name],\n              [\"Email\", d.email],\n              [\"Business\", d.business],\n              [\"Pages\", d.pages],\n              [\"Budget\", d.budget],\n              [\"Notes\", d.notes || \"None\"],\n            ] as const).map(([k, v]) => (\n              <div key={k} className=\"flex gap-4 px-3 py-2.5\">\n                <dt className=\"w-20 shrink-0 text-slate-600\">{k}</dt>\n                <dd className=\"min-w-0 break-words text-slate-900\">{v}</dd>\n              </div>\n            ))}\n          </dl>\n        )}\n\n        <div className=\"mt-5 flex items-center justify-between gap-3\">\n          {step > 0 ? (\n            <button type=\"button\" onClick={back} className=\"h-11 rounded-lg px-4 text-sm font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\">\n              Back\n            </button>\n          ) : (\n            <span />\n          )}\n          <button type=\"submit\" className=\"h-11 rounded-lg bg-teal-700 px-5 text-sm font-semibold text-white hover:bg-teal-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\">\n            {step === 2 ? \"Send request\" : \"Continue\"}\n          </button>\n        </div>\n      </div>\n    </form>\n  );\n}\n\nconst FORM_REACT = `import { useEffect, useRef, useState } from \"react\";\nimport type { FormEvent } from \"react\";\n\ntype Draft = { name: string; email: string; business: string; pages: string; budget: string; notes: string };\nconst EMPTY: Draft = { name: \"\", email: \"\", business: \"\", pages: \"\", budget: \"\", notes: \"\" };\nconst F_STEPS = [\"You\", \"Project\", \"Review\"];\nconst CHECK = \"M5 12.5l4.5 4.5L19 7.5\";\nconst KEY = \"quote-request-draft\";\n// Browser storage can throw (private mode, blocked site data), so every use is wrapped.\nconst store = () => {\n  try {\n    return window[\"local\" + \"Storage\"] as Storage;\n  } catch {\n    return null;\n  }\n};\n\n// Each step is checked only for its own fields when Continue is pressed.\nfunction validate(step: number, d: Draft): Partial<Record<keyof Draft, string>> {\n  const e: Partial<Record<keyof Draft, string>> = {};\n  if (step === 0) {\n    if (!d.name.trim()) e.name = \"Enter your name.\";\n    if (!/^[^\\\\s@]+@[^\\\\s@]+\\\\.[^\\\\s@]+$/.test(d.email)) e.email = \"Enter an email like name@example.com.\";\n  }\n  if (step === 1) {\n    if (!d.business.trim()) e.business = \"Tell us the business name.\";\n    if (!d.pages) e.pages = \"Choose roughly how many pages.\";\n    if (!d.budget) e.budget = \"Pick a budget range.\";\n  }\n  return e;\n}\n\nexport function MultiStepForm() {\n  const [step, setStep] = useState(0);\n  const [d, setD] = useState<Draft>(EMPTY);\n  const [errors, setErrors] = useState<Partial<Record<keyof Draft, string>>>({});\n  const [saved, setSaved] = useState(\"\");\n  const [sent, setSent] = useState(false);\n  const heading = useRef<HTMLHeadingElement | null>(null);\n  const moved = useRef(false);\n\n  // Restore a saved draft on load.\n  useEffect(() => {\n    try {\n      const raw = store()?.getItem(KEY);\n      if (raw) {\n        const v = JSON.parse(raw) as { step: number; d: Draft };\n        setD({ ...EMPTY, ...v.d });\n        setStep(Math.min(Math.max(v.step, 0), 2));\n        setSaved(\"Draft restored\");\n      }\n    } catch {\n      /* storage blocked or bad data: start fresh */\n    }\n  }, []);\n\n  // After changing step, move focus to the new heading so screen readers announce it.\n  useEffect(() => {\n    if (moved.current) heading.current?.focus();\n  }, [step]);\n\n  const save = (nextStep: number, next: Draft) => {\n    try {\n      store()?.setItem(KEY, JSON.stringify({ step: nextStep, d: next }));\n      setSaved(\"Progress saved\");\n    } catch {\n      setSaved(\"\");\n    }\n  };\n\n  const set = (k: keyof Draft, v: string) => {\n    const next = { ...d, [k]: v };\n    setD(next);\n    if (errors[k]) setErrors({ ...errors, [k]: undefined });\n    save(step, next);\n  };\n\n  const onSubmit = (ev: FormEvent<HTMLFormElement>) => {\n    ev.preventDefault();\n    const e = validate(step, d);\n    setErrors(e);\n    const first = Object.keys(e)[0];\n    if (first) {\n      ev.currentTarget.querySelector<HTMLElement>('[name=\"' + first + '\"]')?.focus();\n      return;\n    }\n    if (step < 2) {\n      moved.current = true;\n      setStep(step + 1);\n      save(step + 1, d);\n      return;\n    }\n    // Send d to your server here.\n    setSent(true);\n    try {\n      store()?.removeItem(KEY);\n    } catch {\n      /* ignore */\n    }\n  };\n\n  const back = () => {\n    moved.current = true;\n    setErrors({});\n    setStep(step - 1);\n    save(step - 1, d);\n  };\n\n  const reset = () => {\n    setD(EMPTY);\n    setStep(0);\n    setSent(false);\n    setSaved(\"\");\n    try {\n      store()?.removeItem(KEY);\n    } catch {\n      /* ignore */\n    }\n  };\n\n  const input = (bad?: string) =>\n    \"mt-1.5 block h-11 w-full rounded-lg border bg-white px-3 text-sm text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 \" + (bad ? \"border-red-600\" : \"border-slate-300\");\n  const err = (k: keyof Draft) =>\n    errors[k] ? (\n      <p id={\"msf-\" + k + \"-err\"} className=\"mt-1 text-xs font-medium text-red-700\">\n        {errors[k]}\n      </p>\n    ) : null;\n  const aria = (k: keyof Draft) => ({ \"aria-invalid\": errors[k] ? true : undefined, \"aria-describedby\": errors[k] ? \"msf-\" + k + \"-err\" : undefined });\n\n  if (sent) {\n    return (\n      <div role=\"status\" className=\"rounded-xl border border-teal-200 bg-teal-50 p-6\">\n        <h4 className=\"text-base font-semibold text-teal-950\">Request sent</h4>\n        <p className=\"mt-1 text-sm text-teal-900\">Thanks, {d.name.split(\" \")[0]}. A quote for {d.business} will reach {d.email} within two working days.</p>\n        <button type=\"button\" onClick={reset} className=\"mt-4 h-10 rounded-lg bg-teal-700 px-4 text-sm font-semibold text-white hover:bg-teal-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\">\n          Start a new request\n        </button>\n      </div>\n    );\n  }\n\n  return (\n    <form noValidate onSubmit={onSubmit} className=\"grid gap-6 md:grid-cols-[180px_1fr]\">\n      <ol aria-label=\"Quote request steps\" className=\"flex gap-4 md:flex-col md:gap-3\">\n        {F_STEPS.map((s, i) => (\n          <li key={s} aria-current={i === step ? \"step\" : undefined} className=\"flex items-center gap-2.5 text-sm\">\n            <span className={\"grid h-7 w-7 place-items-center rounded-full text-xs font-semibold \" + (i < step ? \"bg-teal-700 text-white\" : i === step ? \"ring-2 ring-teal-700 text-teal-800\" : \"ring-1 ring-slate-300 text-slate-500\")}>\n              {i < step ? (\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-3.5 w-3.5\">\n                  <path d={CHECK} />\n                </svg>\n              ) : (\n                i + 1\n              )}\n            </span>\n            <span className={i === step ? \"font-semibold text-slate-900\" : \"text-slate-600\"}>{s}</span>\n          </li>\n        ))}\n        <li className=\"ml-auto self-center text-xs text-slate-600 md:ml-0 md:mt-2\" aria-live=\"polite\">\n          {saved}\n        </li>\n      </ol>\n\n      <div className=\"min-w-0\">\n        <h4 ref={heading} tabIndex={-1} className=\"text-base font-semibold text-slate-900 focus:outline-none\">\n          {[\"About you\", \"About the project\", \"Check and send\"][step]}\n        </h4>\n\n        {step === 0 && (\n          <div className=\"mt-4 grid gap-4 sm:grid-cols-2\">\n            <div>\n              <label htmlFor=\"msf-name\" className=\"text-sm font-medium text-slate-800\">Full name</label>\n              <input id=\"msf-name\" name=\"name\" autoComplete=\"name\" value={d.name} onChange={(e) => set(\"name\", e.target.value)} className={input(errors.name)} {...aria(\"name\")} />\n              {err(\"name\")}\n            </div>\n            <div>\n              <label htmlFor=\"msf-email\" className=\"text-sm font-medium text-slate-800\">Email</label>\n              <input id=\"msf-email\" name=\"email\" type=\"email\" autoComplete=\"email\" value={d.email} onChange={(e) => set(\"email\", e.target.value)} className={input(errors.email)} {...aria(\"email\")} />\n              {err(\"email\")}\n            </div>\n          </div>\n        )}\n\n        {step === 1 && (\n          <div className=\"mt-4 grid gap-4 sm:grid-cols-2\">\n            <div className=\"sm:col-span-2\">\n              <label htmlFor=\"msf-business\" className=\"text-sm font-medium text-slate-800\">Business name</label>\n              <input id=\"msf-business\" name=\"business\" autoComplete=\"organization\" value={d.business} onChange={(e) => set(\"business\", e.target.value)} className={input(errors.business)} {...aria(\"business\")} />\n              {err(\"business\")}\n            </div>\n            <div>\n              <label htmlFor=\"msf-pages\" className=\"text-sm font-medium text-slate-800\">Number of pages</label>\n              <select id=\"msf-pages\" name=\"pages\" value={d.pages} onChange={(e) => set(\"pages\", e.target.value)} className={input(errors.pages)} {...aria(\"pages\")}>\n                <option value=\"\">Choose</option>\n                <option>1 to 3</option>\n                <option>4 to 8</option>\n                <option>9 or more</option>\n              </select>\n              {err(\"pages\")}\n            </div>\n            <fieldset aria-describedby={errors.budget ? \"msf-budget-err\" : undefined}>\n              <legend className=\"text-sm font-medium text-slate-800\">Budget</legend>\n              <div className=\"mt-1.5 flex gap-2\">\n                {[\"Under $2k\", \"$2k to $6k\", \"$6k+\"].map((b, k) => (\n                  <label key={b} htmlFor={\"msf-budget-\" + k} className={\"flex h-11 flex-1 cursor-pointer items-center justify-center rounded-lg border px-2 text-center text-xs font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-teal-600 \" + (d.budget === b ? \"border-teal-700 bg-teal-50 text-teal-900\" : errors.budget ? \"border-red-600 text-slate-700\" : \"border-slate-300 text-slate-700\")}>\n                    <input id={\"msf-budget-\" + k} type=\"radio\" name=\"budget\" value={b} checked={d.budget === b} onChange={() => set(\"budget\", b)} className=\"sr-only\" />\n                    {b}\n                  </label>\n                ))}\n              </div>\n              {err(\"budget\")}\n            </fieldset>\n            <div className=\"sm:col-span-2\">\n              <label htmlFor=\"msf-notes\" className=\"text-sm font-medium text-slate-800\">\n                Anything else <span className=\"font-normal text-slate-600\">(optional)</span>\n              </label>\n              <textarea id=\"msf-notes\" name=\"notes\" rows={2} value={d.notes} onChange={(e) => set(\"notes\", e.target.value)} className=\"mt-1.5 block w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\" />\n            </div>\n          </div>\n        )}\n\n        {step === 2 && (\n          <dl className=\"mt-4 divide-y divide-slate-200 rounded-lg border border-slate-200 text-sm\">\n            {([\n              [\"Name\", d.name],\n              [\"Email\", d.email],\n              [\"Business\", d.business],\n              [\"Pages\", d.pages],\n              [\"Budget\", d.budget],\n              [\"Notes\", d.notes || \"None\"],\n            ] as const).map(([k, v]) => (\n              <div key={k} className=\"flex gap-4 px-3 py-2.5\">\n                <dt className=\"w-20 shrink-0 text-slate-600\">{k}</dt>\n                <dd className=\"min-w-0 break-words text-slate-900\">{v}</dd>\n              </div>\n            ))}\n          </dl>\n        )}\n\n        <div className=\"mt-5 flex items-center justify-between gap-3\">\n          {step > 0 ? (\n            <button type=\"button\" onClick={back} className=\"h-11 rounded-lg px-4 text-sm font-medium text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\">\n              Back\n            </button>\n          ) : (\n            <span />\n          )}\n          <button type=\"submit\" className=\"h-11 rounded-lg bg-teal-700 px-5 text-sm font-semibold text-white hover:bg-teal-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\">\n            {step === 2 ? \"Send request\" : \"Continue\"}\n          </button>\n        </div>\n      </div>\n    </form>\n  );\n}`;\n\n/* ---------- catalogue ---------- */\nconst ITEMS: Item[] = [\n  { f: \"form\", name: \"Multi-step form with saved progress\", note: \"Validates each step, focuses the first error, and restores the draft after a refresh. Press Continue with empty fields to see it.\", Demo: MultiStepForm, code: { react: FORM_REACT }, wide: true },\n  { f: \"steppers\", name: \"Horizontal numbered\", note: \"Completed steps are clickable. Labels give way to a Step 2 of 4 line on phones.\", Demo: HorizontalStepper, code: { react: HORIZONTAL_REACT, html: HORIZONTAL_HTML } },\n  { f: \"steppers\", name: \"Segmented progress bar\", note: \"One progressbar with the stage name as its value text.\", Demo: ProgressStepper, code: { react: PROGRESS_REACT } },\n  { f: \"steppers\", name: \"Vertical with descriptions\", note: \"Only the current step opens, so a long checklist stays short.\", Demo: VerticalStepper, code: { react: VERTICAL_REACT } },\n  { f: \"steppers\", name: \"Chevron checkout steps\", note: \"Arrow segments for flows where any step can be revisited.\", Demo: ChevronStepper, code: { react: CHEVRON_REACT } },\n  { f: \"steppers\", name: \"Dot stepper for tips\", note: \"Small dots, full-size tap targets and labels.\", Demo: DotStepper, code: { react: DOT_REACT } },\n];\n\nconst REF: [string, string][] = [\n  [\"aria-current=\\\"step\\\"\", \"Marks the active item in a list of steps. Put it on exactly one item and move it as the user advances.\"],\n  [\"Ordered list\", \"An ol tells assistive technology how many steps there are and where each one sits, so \\\"2 of 4\\\" is announced for free.\"],\n  [\"Completed state\", \"Add hidden text such as \\\", completed\\\" next to the check mark, because an icon alone is not read out.\"],\n  [\"Focus on step change\", \"Move focus to the new step's heading (tabIndex -1) so keyboard users start at the top of it and screen readers announce the change.\"],\n  [\"Errors\", \"Set aria-invalid on the field and link the message with aria-describedby, then focus the first field that failed.\"],\n];\n\nconst RING = \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-700 focus-visible:ring-offset-2 focus-visible:ring-offset-[#f3f6f7]\";\n\nfunction Card({ item, n }: { item: Item; n: number }) {\n  const langs = Object.keys(item.code) as Lang[];\n  const [lang, setLang] = useState<Lang>(langs[0]);\n  const [open, setOpen] = useState(false);\n  const [copied, setCopied] = useState(false);\n  const [msg, setMsg] = useState(\"\");\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  useEffect(() => () => {\n    if (timer.current) clearTimeout(timer.current);\n  }, []);\n  const code = item.code[lang] ?? \"\";\n  const id = `rs-code-${n}`;\n  async function copy() {\n    let ok = false;\n    try {\n      await navigator.clipboard.writeText(code);\n      ok = true;\n    } catch {\n      ok = false;\n    }\n    if (!ok) setOpen(true);\n    setCopied(ok);\n    setMsg(ok ? `${item.name}, ${LANGS[lang]}, copied` : \"Copy was blocked. The code is open below so you can select it.\");\n    if (timer.current) clearTimeout(timer.current);\n    timer.current = setTimeout(() => setCopied(false), 1600);\n  }\n  const Demo = item.Demo;\n  const tool = `inline-flex h-10 items-center justify-center gap-1.5 rounded-lg px-3 text-[12.5px] font-semibold transition-colors ${RING}`;\n  return (\n    <li className={`flex min-w-0 flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-[0_1px_2px_rgba(15,23,42,0.05)] ${item.wide || open ? \"lg:col-span-2\" : \"\"}`}>\n      <div className=\"flex items-start gap-3 px-5 pt-4\">\n        <span className=\"mt-0.5 font-mono text-[11px] text-slate-500\">{String(n).padStart(2, \"0\")}</span>\n        <div className=\"min-w-0\">\n          <h3 className=\"text-[15px] font-semibold tracking-tight text-slate-900\">{item.name}</h3>\n          <p className=\"mt-0.5 text-[13px] leading-snug text-slate-600\">{item.note}</p>\n        </div>\n      </div>\n      <div className=\"flex flex-1 items-center px-5 py-6\">\n        <div className=\"w-full min-w-0\">\n          <Demo />\n        </div>\n      </div>\n      <div className=\"flex flex-wrap items-center gap-2 border-t border-slate-200 bg-slate-50/70 px-3 py-2\">\n        {langs.length > 1 ? (\n          <div role=\"group\" aria-label={`Code version for ${item.name}`} className=\"flex rounded-lg bg-slate-200/70 p-0.5\">\n            {langs.map((l) => (\n              <button key={l} type=\"button\" aria-pressed={lang === l} onClick={() => setLang(l)} className={`h-9 rounded-md px-2.5 text-[12px] font-medium ${RING} ${lang === l ? \"bg-white text-slate-900 shadow-sm\" : \"text-slate-600 hover:text-slate-900\"}`}>\n                {LANGS[l]}\n              </button>\n            ))}\n          </div>\n        ) : (\n          <span className=\"px-1 text-[12px] font-medium text-slate-600\">{LANGS[lang]}</span>\n        )}\n        <span className=\"flex-1\" />\n        <button type=\"button\" aria-expanded={open} aria-controls={id} onClick={() => setOpen(!open)} className={`${tool} text-slate-700 hover:bg-slate-200/70`}>\n          {open ? \"Hide code\" : \"Show code\"}\n        </button>\n        <button type=\"button\" onClick={copy} aria-label={`Copy ${LANGS[lang]} code for ${item.name}`} className={`${tool} ${copied ? \"bg-emerald-700 text-white\" : \"bg-slate-900 text-white hover:bg-slate-700\"}`}>\n          {copied ? \"Copied\" : \"Copy\"}\n        </button>\n      </div>\n      <p className=\"sr-only\" aria-live=\"polite\">\n        {msg}\n      </p>\n      {open && (\n        <pre id={id} tabIndex={0} aria-label={`${item.name} code`} className={`max-h-96 overflow-auto border-t border-slate-800 bg-[#0f1419] p-4 font-mono text-[11.5px] leading-[1.65] text-slate-200 ${RING}`}>\n          <code>{code}</code>\n        </pre>\n      )}\n    </li>\n  );\n}\n\nconst FAM_KEYS = Object.keys(FAMILIES) as Fam[];\n\nexport default function ReactStepperCollection() {\n  const [fam, setFam] = useState<Fam | \"all\">(\"all\");\n  const list = ITEMS.map((it, i) => ({ it, n: i + 1 })).filter(({ it }) => fam === \"all\" || it.f === fam);\n  const chip = `inline-flex min-h-[40px] items-center gap-1.5 whitespace-nowrap rounded-full px-3.5 text-[13px] font-medium transition-colors ${RING}`;\n  return (\n    <section className=\"bg-[#f3f6f7] px-4 py-12 text-slate-900 sm:px-8 sm:py-14\" style={{ fontFamily: '\"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif' }}>\n      <div className=\"mx-auto max-w-6xl\">\n        <header className=\"flex flex-col gap-6 md:flex-row md:items-end md:justify-between\">\n          <div className=\"max-w-3xl\">\n            <p className=\"font-mono text-[12px] uppercase tracking-[0.18em] text-slate-600\">React · Tailwind · no dependencies</p>\n            <h2 className=\"mt-3 text-[32px] font-semibold leading-[1.05] tracking-[-0.03em] sm:text-[44px]\">React steppers and a multi-step form</h2>\n            <p className=\"mt-4 max-w-xl text-[15px] leading-relaxed text-slate-600\">\n              Five stepper layouts and one complete form that checks each step before moving on and keeps its draft if the tab is closed. Try them, then copy the source.\n            </p>\n          </div>\n          <div className=\"flex flex-wrap gap-1.5\" role=\"group\" aria-label=\"Filter by kind\">\n            {([\"all\", ...FAM_KEYS] as const).map((f) => {\n              const on = fam === f;\n              const count = f === \"all\" ? ITEMS.length : ITEMS.filter((it) => it.f === f).length;\n              return (\n                <button key={f} type=\"button\" aria-pressed={on} onClick={() => setFam(f)} className={`${chip} ${on ? \"bg-slate-900 text-white\" : \"bg-white text-slate-700 ring-1 ring-inset ring-slate-300 hover:bg-slate-100\"}`}>\n                  {f === \"all\" ? \"All\" : FAMILIES[f]}\n                  <span className={`font-mono text-[11px] ${on ? \"opacity-70\" : \"text-slate-500\"}`}>{count}</span>\n                </button>\n              );\n            })}\n          </div>\n        </header>\n\n        <div className=\"mt-8 h-[1180px] overflow-y-auto overscroll-contain border-t border-slate-300/70 pr-1 pt-6\" tabIndex={0} aria-label=\"Stepper examples and reference\">\n          <ul className=\"grid grid-cols-1 gap-4 lg:grid-cols-2\">\n            {list.map(({ it, n }) => (\n              <Card key={n} item={it} n={n} />\n            ))}\n          </ul>\n          <div className=\"mt-10 rounded-2xl border border-slate-200 bg-white p-5 sm:p-6\">\n            <h3 className=\"text-lg font-semibold tracking-tight\">Accessible stepper checklist</h3>\n            <dl className=\"mt-4 divide-y divide-slate-100 text-[13px]\">\n              {REF.map(([a, b]) => (\n                <div key={a} className=\"grid gap-1 py-2.5 sm:grid-cols-[200px_1fr] sm:gap-4\">\n                  <dt className=\"font-mono font-semibold text-slate-900\">{a}</dt>\n                  <dd className=\"leading-relaxed text-slate-700\">{b}</dd>\n                </div>\n              ))}\n            </dl>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
