{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"html-form-examples-collection-with-every-input-type-and-copyable-html-css-or-tailwind","type":"registry:block","title":"HTML Form Examples with Every Input Type, Copyable as HTML + CSS or Tailwind","description":"Free HTML form examples: contact, signup, login, checkout, booking, survey and more, covering every input type. Copy each as HTML with CSS or as Tailwind.","dependencies":[],"files":[{"path":"components/we-inc/html-form-examples-collection-with-every-input-type-and-copyable-html-css-or-tailwind.tsx","type":"registry:component","content":"import { createElement, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode, SyntheticEvent } from \"react\";\n\n/*\n  HTML form examples.\n  Every form is written once as a small tree of elements. Each element carries two class lists:\n  Tailwind utilities and a plain semantic class (f-field, f-input...). The same tree renders the\n  live preview, the plain HTML + CSS you copy and the Tailwind HTML you copy.\n*/\n\ntype Attrs = Record<string, string>;\ntype El = { t: string; c?: string; s?: string; a?: Attrs; k: N[] };\ntype N = string | El;\ntype Kid = N | { $: Attrs } | null | false | undefined;\n\nfunction h(t: string, c: string, s: string, ...kids: Kid[]): El {\n  const el: El = { t, c: c || undefined, s: s || undefined, k: [] };\n  for (const kid of kids) {\n    if (kid === null || kid === false || kid === undefined) continue;\n    if (typeof kid === \"object\" && \"$\" in kid) el.a = { ...(el.a ?? {}), ...kid.$ };\n    else el.k.push(kid);\n  }\n  return el;\n}\nconst $ = (a: Attrs) => ({ $: a });\n\n/* ---------- themes: literal Tailwind fragments + the matching plain CSS values ---------- */\ntype Css = { bg: string; card: string; text: string; muted: string; border: string; input: string; accent: string; on: string; err: string; ok: string; r: string; r2: string; font: string };\ntype ThIn = {\n  wrap: string; card: string; title: string; eyebrow: string; muted: string; label: string; input: string;\n  acc: string; btn: string; btn2: string; err: string; stat: string; sw: string; file: string; css: Css;\n};\ntype Th = ThIn & { help: string; check: string; range: string; color: string; btnBase: string };\n\nconst SANS = \"system-ui, -apple-system, 'Segoe UI', sans-serif\";\nconst SERIF = \"Georgia, 'Times New Roman', serif\";\nconst mk = (t: ThIn): Th => ({\n  ...t,\n  help: `text-[13px] leading-5 ${t.muted}`,\n  check: `h-[18px] w-[18px] shrink-0 cursor-pointer ${t.acc}`,\n  range: `h-2 w-full cursor-pointer ${t.acc}`,\n  color: \"h-11 w-20 cursor-pointer rounded-md border border-current/20 bg-transparent p-1\",\n  btnBase: \"inline-flex min-h-[44px] items-center justify-center gap-2 px-5 text-sm font-semibold transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2\",\n});\n\nconst T = {\n  stone: mk({\n    wrap: \"bg-[#efebe4]\", card: \"rounded-2xl bg-white shadow-sm ring-1 ring-stone-200\", title: \"font-serif text-stone-900\", eyebrow: \"text-teal-800\",\n    muted: \"text-stone-600\", label: \"text-stone-900\",\n    input: \"rounded-lg border border-stone-300 bg-white text-stone-900 placeholder:text-stone-500 focus:border-teal-700 focus:ring-4 focus:ring-teal-700/15 aria-[invalid=true]:border-red-600\",\n    acc: \"accent-teal-700\", btn: \"rounded-lg bg-teal-800 text-white hover:bg-teal-900 focus-visible:ring-teal-700\", btn2: \"rounded-lg border border-stone-300 text-stone-800 hover:bg-stone-100 focus-visible:ring-teal-700\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-teal-800 data-[state=error]:text-red-700\", sw: \"bg-stone-300 checked:bg-teal-700 focus-visible:ring-teal-700\", file: \"file:bg-teal-800 file:text-white\",\n    css: { bg: \"#efebe4\", card: \"#ffffff\", text: \"#1c1917\", muted: \"#57534e\", border: \"#d6d3d1\", input: \"#ffffff\", accent: \"#115e59\", on: \"#ffffff\", err: \"#b91c1c\", ok: \"#115e59\", r: \"16px\", r2: \"8px\", font: SERIF },\n  }),\n  tide: mk({\n    wrap: \"bg-[#0b1626]\", card: \"rounded-none border border-amber-300/30 bg-[#0f1f35]\", title: \"text-amber-50\", eyebrow: \"text-amber-300\",\n    muted: \"text-slate-300\", label: \"text-amber-50\",\n    input: \"rounded-none border border-slate-500 bg-[#0b1626] text-white placeholder:text-slate-400 focus:border-amber-300 focus:ring-4 focus:ring-amber-300/20 aria-[invalid=true]:border-rose-400\",\n    acc: \"accent-amber-400\", btn: \"rounded-none bg-amber-300 text-[#0b1626] hover:bg-amber-200 focus-visible:ring-amber-300 focus-visible:ring-offset-[#0f1f35]\", btn2: \"rounded-none border border-slate-500 text-slate-100 hover:bg-white/5 focus-visible:ring-amber-300\",\n    err: \"text-rose-300\", stat: \"data-[state=ok]:text-amber-200 data-[state=error]:text-rose-300\", sw: \"bg-slate-600 checked:bg-amber-400 focus-visible:ring-amber-300\", file: \"file:bg-amber-300 file:text-slate-900\",\n    css: { bg: \"#0b1626\", card: \"#0f1f35\", text: \"#fffbeb\", muted: \"#cbd5e1\", border: \"#64748b\", input: \"#0b1626\", accent: \"#fcd34d\", on: \"#0b1626\", err: \"#fda4af\", ok: \"#fde68a\", r: \"0\", r2: \"0\", font: SERIF },\n  }),\n  violet: mk({\n    wrap: \"bg-violet-50\", card: \"rounded-3xl bg-white shadow-[0_10px_40px_-20px_rgba(76,29,149,0.35)] ring-1 ring-violet-100\", title: \"text-slate-900\", eyebrow: \"text-violet-700\",\n    muted: \"text-slate-600\", label: \"text-slate-800\",\n    input: \"rounded-xl border border-slate-300 bg-slate-50 text-slate-900 placeholder:text-slate-500 focus:border-violet-600 focus:bg-white focus:ring-4 focus:ring-violet-600/15 aria-[invalid=true]:border-rose-600\",\n    acc: \"accent-violet-600\", btn: \"rounded-full bg-violet-600 text-white hover:bg-violet-700 focus-visible:ring-violet-600\", btn2: \"rounded-full border border-slate-300 text-slate-800 hover:bg-slate-50 focus-visible:ring-violet-600\",\n    err: \"text-rose-700\", stat: \"data-[state=ok]:text-violet-700 data-[state=error]:text-rose-700\", sw: \"bg-slate-300 checked:bg-violet-600 focus-visible:ring-violet-600\", file: \"file:bg-violet-600 file:text-white\",\n    css: { bg: \"#f5f3ff\", card: \"#ffffff\", text: \"#0f172a\", muted: \"#475569\", border: \"#cbd5e1\", input: \"#f8fafc\", accent: \"#7c3aed\", on: \"#ffffff\", err: \"#be123c\", ok: \"#6d28d9\", r: \"24px\", r2: \"12px\", font: SANS },\n  }),\n  quarry: mk({\n    wrap: \"bg-slate-950\", card: \"rounded-xl border border-slate-800 bg-slate-900\", title: \"text-white\", eyebrow: \"text-emerald-400\",\n    muted: \"text-slate-400\", label: \"text-slate-100\",\n    input: \"rounded-lg border border-slate-700 bg-slate-950 text-white placeholder:text-slate-500 focus:border-emerald-400 focus:ring-4 focus:ring-emerald-400/15 aria-[invalid=true]:border-rose-400\",\n    acc: \"accent-emerald-500\", btn: \"rounded-lg bg-emerald-400 text-slate-950 hover:bg-emerald-300 focus-visible:ring-emerald-400 focus-visible:ring-offset-slate-900\", btn2: \"rounded-lg border border-slate-700 text-slate-200 hover:bg-slate-800 focus-visible:ring-emerald-400\",\n    err: \"text-rose-300\", stat: \"data-[state=ok]:text-emerald-300 data-[state=error]:text-rose-300\", sw: \"bg-slate-700 checked:bg-emerald-500 focus-visible:ring-emerald-400\", file: \"file:bg-emerald-400 file:text-slate-950\",\n    css: { bg: \"#020617\", card: \"#0f172a\", text: \"#f1f5f9\", muted: \"#94a3b8\", border: \"#334155\", input: \"#020617\", accent: \"#34d399\", on: \"#020617\", err: \"#fda4af\", ok: \"#6ee7b7\", r: \"12px\", r2: \"8px\", font: SANS },\n  }),\n  roast: mk({\n    wrap: \"bg-[#f7efe3]\", card: \"rounded-2xl bg-[#fffaf2] ring-1 ring-amber-900/15\", title: \"text-[#3b2412]\", eyebrow: \"text-amber-800\",\n    muted: \"text-[#6b4f36]\", label: \"text-[#3b2412]\",\n    input: \"rounded-md border border-[#d9c3a5] bg-white text-[#3b2412] placeholder:text-[#8a6d52] focus:border-amber-700 focus:ring-4 focus:ring-amber-700/15 aria-[invalid=true]:border-red-700\",\n    acc: \"accent-amber-700\", btn: \"rounded-md bg-[#3b2412] text-amber-50 hover:bg-[#2a190c] focus-visible:ring-amber-700\", btn2: \"rounded-md border border-[#d9c3a5] text-[#3b2412] hover:bg-amber-50 focus-visible:ring-amber-700\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-green-800 data-[state=error]:text-red-700\", sw: \"bg-[#d9c3a5] checked:bg-amber-700 focus-visible:ring-amber-700\", file: \"file:bg-[#3b2412] file:text-amber-50\",\n    css: { bg: \"#f7efe3\", card: \"#fffaf2\", text: \"#3b2412\", muted: \"#6b4f36\", border: \"#d9c3a5\", input: \"#ffffff\", accent: \"#3b2412\", on: \"#fffbeb\", err: \"#b91c1c\", ok: \"#166534\", r: \"16px\", r2: \"6px\", font: SANS },\n  }),\n  field: mk({\n    wrap: \"bg-emerald-950\", card: \"rounded-2xl bg-[#f4f7f1]\", title: \"text-emerald-950\", eyebrow: \"text-emerald-700\",\n    muted: \"text-slate-600\", label: \"text-emerald-950\",\n    input: \"rounded-lg border-2 border-emerald-900/15 bg-white text-slate-900 placeholder:text-slate-500 focus:border-emerald-600 focus:ring-0 aria-[invalid=true]:border-red-600\",\n    acc: \"accent-emerald-700\", btn: \"rounded-lg bg-emerald-700 text-white hover:bg-emerald-800 focus-visible:ring-emerald-700\", btn2: \"rounded-lg border-2 border-emerald-900/15 text-emerald-950 hover:bg-white focus-visible:ring-emerald-700\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-emerald-800 data-[state=error]:text-red-700\", sw: \"bg-slate-300 checked:bg-emerald-700 focus-visible:ring-emerald-700\", file: \"file:bg-emerald-700 file:text-white\",\n    css: { bg: \"#022c22\", card: \"#f4f7f1\", text: \"#022c22\", muted: \"#475569\", border: \"#cfd8d3\", input: \"#ffffff\", accent: \"#047857\", on: \"#ffffff\", err: \"#b91c1c\", ok: \"#065f46\", r: \"16px\", r2: \"8px\", font: SANS },\n  }),\n  rose: mk({\n    wrap: \"bg-rose-50\", card: \"rounded-[28px] bg-white ring-1 ring-rose-200\", title: \"text-rose-950\", eyebrow: \"text-rose-700\",\n    muted: \"text-slate-600\", label: \"text-slate-900\",\n    input: \"rounded-2xl border border-rose-200 bg-white text-slate-900 placeholder:text-slate-500 focus:border-rose-500 focus:ring-4 focus:ring-rose-500/15 aria-[invalid=true]:border-red-600\",\n    acc: \"accent-rose-600\", btn: \"rounded-full bg-rose-600 text-white hover:bg-rose-700 focus-visible:ring-rose-600\", btn2: \"rounded-full border border-rose-200 text-rose-900 hover:bg-rose-50 focus-visible:ring-rose-600\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-rose-800 data-[state=error]:text-red-700\", sw: \"bg-rose-200 checked:bg-rose-600 focus-visible:ring-rose-600\", file: \"file:bg-rose-600 file:text-white\",\n    css: { bg: \"#fff1f2\", card: \"#ffffff\", text: \"#0f172a\", muted: \"#475569\", border: \"#fecdd3\", input: \"#ffffff\", accent: \"#e11d48\", on: \"#ffffff\", err: \"#b91c1c\", ok: \"#9f1239\", r: \"28px\", r2: \"16px\", font: SANS },\n  }),\n  beam: mk({\n    wrap: \"bg-[#0d0b1f]\", card: \"rounded-2xl border border-indigo-400/20 bg-[#151233]\", title: \"text-white\", eyebrow: \"text-indigo-300\",\n    muted: \"text-indigo-200\", label: \"text-white\",\n    input: \"rounded-lg border border-indigo-400/30 bg-[#0d0b1f] text-white placeholder:text-indigo-300/70 focus:border-indigo-300 focus:ring-4 focus:ring-indigo-400/20 aria-[invalid=true]:border-rose-400\",\n    acc: \"accent-indigo-400\", btn: \"rounded-lg bg-indigo-400 text-[#0d0b1f] hover:bg-indigo-300 focus-visible:ring-indigo-300 focus-visible:ring-offset-[#151233]\", btn2: \"rounded-lg border border-indigo-400/30 text-indigo-100 hover:bg-white/5 focus-visible:ring-indigo-300\",\n    err: \"text-rose-300\", stat: \"data-[state=ok]:text-indigo-200 data-[state=error]:text-rose-300\", sw: \"bg-indigo-900 checked:bg-indigo-400 focus-visible:ring-indigo-300\", file: \"file:bg-indigo-400 file:text-[#0d0b1f]\",\n    css: { bg: \"#0d0b1f\", card: \"#151233\", text: \"#ffffff\", muted: \"#c7d2fe\", border: \"#3f3a7a\", input: \"#0d0b1f\", accent: \"#818cf8\", on: \"#0d0b1f\", err: \"#fda4af\", ok: \"#c7d2fe\", r: \"16px\", r2: \"8px\", font: SANS },\n  }),\n  sky: mk({\n    wrap: \"bg-sky-100\", card: \"rounded-xl bg-white shadow-sm ring-1 ring-sky-200\", title: \"text-slate-900\", eyebrow: \"text-sky-800\",\n    muted: \"text-slate-600\", label: \"text-slate-800\",\n    input: \"rounded-md border border-slate-300 bg-white text-slate-900 placeholder:text-slate-500 focus:border-sky-700 focus:ring-4 focus:ring-sky-600/15 aria-[invalid=true]:border-red-600\",\n    acc: \"accent-sky-700\", btn: \"rounded-md bg-sky-700 text-white hover:bg-sky-800 focus-visible:ring-sky-700\", btn2: \"rounded-md border border-slate-300 text-slate-800 hover:bg-slate-50 focus-visible:ring-sky-700\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-sky-800 data-[state=error]:text-red-700\", sw: \"bg-slate-300 checked:bg-sky-700 focus-visible:ring-sky-700\", file: \"file:bg-sky-700 file:text-white\",\n    css: { bg: \"#e0f2fe\", card: \"#ffffff\", text: \"#0f172a\", muted: \"#475569\", border: \"#cbd5e1\", input: \"#ffffff\", accent: \"#0369a1\", on: \"#ffffff\", err: \"#b91c1c\", ok: \"#075985\", r: \"12px\", r2: \"6px\", font: SANS },\n  }),\n  plum: mk({\n    wrap: \"bg-[#2a0f24]\", card: \"rounded-[22px] border border-fuchsia-200/15 bg-[#3a1532]\", title: \"font-serif text-[#ffe9c7]\", eyebrow: \"text-orange-300\",\n    muted: \"text-fuchsia-100/80\", label: \"text-[#ffe9c7]\",\n    input: \"rounded-xl border border-fuchsia-200/25 bg-[#2a0f24] text-white placeholder:text-fuchsia-200/60 focus:border-orange-300 focus:ring-4 focus:ring-orange-300/20 aria-[invalid=true]:border-rose-400\",\n    acc: \"accent-orange-400\", btn: \"rounded-xl bg-orange-300 text-[#2a0f24] hover:bg-orange-200 focus-visible:ring-orange-300 focus-visible:ring-offset-[#3a1532]\", btn2: \"rounded-xl border border-fuchsia-200/25 text-fuchsia-50 hover:bg-white/5 focus-visible:ring-orange-300\",\n    err: \"text-rose-300\", stat: \"data-[state=ok]:text-orange-200 data-[state=error]:text-rose-300\", sw: \"bg-fuchsia-950 checked:bg-orange-400 focus-visible:ring-orange-300\", file: \"file:bg-orange-300 file:text-[#2a0f24]\",\n    css: { bg: \"#2a0f24\", card: \"#3a1532\", text: \"#ffe9c7\", muted: \"#f5d0fe\", border: \"#6b3a60\", input: \"#2a0f24\", accent: \"#fdba74\", on: \"#2a0f24\", err: \"#fda4af\", ok: \"#fed7aa\", r: \"22px\", r2: \"12px\", font: SERIF },\n  }),\n  harbour: mk({\n    wrap: \"bg-white\", card: \"rounded-lg border border-slate-200 bg-slate-50\", title: \"text-slate-900\", eyebrow: \"text-blue-700\",\n    muted: \"text-slate-600\", label: \"text-slate-800\",\n    input: \"rounded-md border border-slate-300 bg-white text-slate-900 placeholder:text-slate-500 focus:border-blue-600 focus:ring-4 focus:ring-blue-600/15 aria-[invalid=true]:border-red-600\",\n    acc: \"accent-blue-600\", btn: \"rounded-md bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-600\", btn2: \"rounded-md border border-slate-300 bg-white text-slate-800 hover:bg-slate-100 focus-visible:ring-blue-600\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-blue-800 data-[state=error]:text-red-700\", sw: \"bg-slate-300 checked:bg-blue-600 focus-visible:ring-blue-600\", file: \"file:bg-blue-600 file:text-white\",\n    css: { bg: \"#ffffff\", card: \"#f8fafc\", text: \"#0f172a\", muted: \"#475569\", border: \"#cbd5e1\", input: \"#ffffff\", accent: \"#2563eb\", on: \"#ffffff\", err: \"#b91c1c\", ok: \"#1e40af\", r: \"8px\", r2: \"6px\", font: SANS },\n  }),\n  pine: mk({\n    wrap: \"bg-zinc-900\", card: \"rounded-2xl bg-zinc-800 ring-1 ring-white/10\", title: \"text-zinc-50\", eyebrow: \"text-teal-300\",\n    muted: \"text-zinc-400\", label: \"text-zinc-100\",\n    input: \"rounded-lg border border-zinc-600 bg-zinc-900 text-zinc-50 placeholder:text-zinc-500 focus:border-teal-300 focus:ring-4 focus:ring-teal-300/15 aria-[invalid=true]:border-rose-400\",\n    acc: \"accent-teal-400\", btn: \"rounded-lg bg-teal-300 text-zinc-900 hover:bg-teal-200 focus-visible:ring-teal-300 focus-visible:ring-offset-zinc-800\", btn2: \"rounded-lg border border-zinc-600 text-zinc-100 hover:bg-zinc-700 focus-visible:ring-teal-300\",\n    err: \"text-rose-300\", stat: \"data-[state=ok]:text-teal-300 data-[state=error]:text-rose-300\", sw: \"bg-zinc-600 checked:bg-teal-400 focus-visible:ring-teal-300\", file: \"file:bg-teal-300 file:text-zinc-900\",\n    css: { bg: \"#18181b\", card: \"#27272a\", text: \"#fafafa\", muted: \"#a1a1aa\", border: \"#52525b\", input: \"#18181b\", accent: \"#5eead4\", on: \"#18181b\", err: \"#fda4af\", ok: \"#5eead4\", r: \"16px\", r2: \"8px\", font: SANS },\n  }),\n  grid: mk({\n    wrap: \"bg-[#f3f4f6]\", card: \"rounded-md border-t-4 border-orange-500 bg-white shadow-sm\", title: \"text-slate-900\", eyebrow: \"text-orange-700\",\n    muted: \"text-slate-600\", label: \"text-slate-900\",\n    input: \"rounded border border-slate-300 bg-white font-mono text-slate-900 placeholder:text-slate-500 focus:border-orange-600 focus:ring-4 focus:ring-orange-500/15 aria-[invalid=true]:border-red-600\",\n    acc: \"accent-orange-600\", btn: \"rounded bg-slate-900 text-white hover:bg-slate-800 focus-visible:ring-orange-500\", btn2: \"rounded border border-slate-300 text-slate-800 hover:bg-slate-50 focus-visible:ring-orange-500\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-green-800 data-[state=error]:text-red-700\", sw: \"bg-slate-300 checked:bg-orange-600 focus-visible:ring-orange-500\", file: \"file:bg-slate-900 file:text-white\",\n    css: { bg: \"#f3f4f6\", card: \"#ffffff\", text: \"#0f172a\", muted: \"#475569\", border: \"#cbd5e1\", input: \"#ffffff\", accent: \"#0f172a\", on: \"#ffffff\", err: \"#b91c1c\", ok: \"#166534\", r: \"6px\", r2: \"4px\", font: SANS },\n  }),\n  brick: mk({\n    wrap: \"bg-[#fbf7f4]\", card: \"rounded-none border-2 border-stone-900 bg-white shadow-[6px_6px_0_0_#1c1917]\", title: \"uppercase tracking-wide text-stone-900\", eyebrow: \"text-red-700\",\n    muted: \"text-stone-600\", label: \"text-stone-900\",\n    input: \"rounded-none border-2 border-stone-900 bg-white text-stone-900 placeholder:text-stone-500 focus:border-red-700 focus:ring-0 aria-[invalid=true]:border-red-700 aria-[invalid=true]:bg-red-50\",\n    acc: \"accent-red-700\", btn: \"rounded-none border-2 border-stone-900 bg-red-700 text-white hover:bg-red-800 focus-visible:ring-stone-900\", btn2: \"rounded-none border-2 border-stone-900 text-stone-900 hover:bg-stone-100 focus-visible:ring-stone-900\",\n    err: \"text-red-700\", stat: \"data-[state=ok]:text-green-800 data-[state=error]:text-red-700\", sw: \"bg-stone-300 checked:bg-red-700 focus-visible:ring-stone-900\", file: \"file:bg-stone-900 file:text-white\",\n    css: { bg: \"#fbf7f4\", card: \"#ffffff\", text: \"#1c1917\", muted: \"#57534e\", border: \"#1c1917\", input: \"#ffffff\", accent: \"#b91c1c\", on: \"#ffffff\", err: \"#b91c1c\", ok: \"#166534\", r: \"0\", r2: \"0\", font: SANS },\n  }),\n  lumen: mk({\n    wrap: \"bg-gradient-to-br from-cyan-950 to-slate-950\", card: \"rounded-3xl border border-cyan-300/15 bg-slate-900/80\", title: \"text-white\", eyebrow: \"text-cyan-300\",\n    muted: \"text-slate-300\", label: \"text-cyan-50\",\n    input: \"rounded-xl border border-slate-600 bg-slate-950 text-white placeholder:text-slate-500 focus:border-cyan-300 focus:ring-4 focus:ring-cyan-300/15 aria-[invalid=true]:border-rose-400\",\n    acc: \"accent-cyan-400\", btn: \"rounded-xl bg-cyan-300 text-slate-950 hover:bg-cyan-200 focus-visible:ring-cyan-300 focus-visible:ring-offset-slate-900\", btn2: \"rounded-xl border border-slate-600 text-slate-100 hover:bg-white/5 focus-visible:ring-cyan-300\",\n    err: \"text-rose-300\", stat: \"data-[state=ok]:text-cyan-200 data-[state=error]:text-rose-300\", sw: \"bg-slate-600 checked:bg-cyan-400 focus-visible:ring-cyan-300\", file: \"file:bg-cyan-300 file:text-slate-950\",\n    css: { bg: \"#083344\", card: \"#0f172a\", text: \"#ecfeff\", muted: \"#cbd5e1\", border: \"#475569\", input: \"#020617\", accent: \"#67e8f9\", on: \"#020617\", err: \"#fda4af\", ok: \"#a5f3fc\", r: \"24px\", r2: \"12px\", font: SANS },\n  }),\n};\n\n/* ---------- builders ---------- */\nconst INPUT = \"block min-h-[44px] w-full px-3 py-2 text-[15px] outline-none transition\";\nconst FILE = \"block w-full cursor-pointer text-sm file:mr-3 file:cursor-pointer file:rounded-md file:border-0 file:px-3 file:py-2 file:text-sm file:font-semibold\";\n\ntype Opt = [string, string];\ntype FieldO = {\n  id: string; label: string; type?: string; tag?: \"input\" | \"select\" | \"textarea\"; a?: Attrs;\n  help?: string; err?: string; opts?: Opt[]; list?: string[]; span?: boolean;\n};\n\nfunction describe(id: string, help?: string): Attrs {\n  return help ? { \"aria-describedby\": `${id}-help` } : {};\n}\nconst helpP = (t: Th, id: string, text?: string) => (text ? h(\"p\", t.help, \"f-help\", $({ id: `${id}-help` }), text) : null);\nconst errP = (t: Th, id: string, text?: string) => (text ? h(\"p\", `text-[13px] font-medium ${t.err}`, \"f-error\", $({ id: `${id}-err`, hidden: \"\" }), text) : null);\n\nfunction field(t: Th, o: FieldO): El {\n  const tag = o.tag ?? \"input\";\n  const type = o.type ?? \"text\";\n  const base: Attrs = { id: o.id, name: o.a?.name ?? o.id, ...describe(o.id, o.help), ...(o.a ?? {}) };\n  let control: El;\n  let after: El | null = null;\n  if (tag === \"select\") {\n    control = h(\"select\", `${INPUT} ${t.input}`, \"f-input\", $(base), h(\"option\", \"\", \"\", $({ value: \"\" }), \"Choose one\"), ...(o.opts ?? []).map(([v, l]) => h(\"option\", \"\", \"\", $({ value: v }), l)));\n  } else if (tag === \"textarea\") {\n    control = h(\"textarea\", `${INPUT} min-h-[104px] ${t.input}`, \"f-input\", $({ rows: \"4\", ...base }));\n  } else if (type === \"file\") {\n    control = h(\"input\", `${FILE} ${t.muted} ${t.file} rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-current`, \"f-file\", $({ type, ...base }));\n  } else if (type === \"color\") {\n    control = h(\"input\", t.color, \"f-color\", $({ type, ...base }));\n  } else {\n    const listA: Attrs = o.list ? { list: `${o.id}-list` } : {};\n    control = h(\"input\", `${INPUT} ${t.input}`, \"f-input\", $({ type, ...base, ...listA }));\n    if (o.list) after = h(\"datalist\", \"\", \"\", $({ id: `${o.id}-list` }), ...o.list.map((v) => h(\"option\", \"\", \"\", $({ value: v }))));\n  }\n  return h(\"div\", `flex flex-col gap-1.5 ${o.span ? \"sm:col-span-2\" : \"\"}`.trim(), o.span ? \"f-field f-span\" : \"f-field\",\n    h(\"label\", `text-sm font-medium ${t.label}`, \"f-label\", $({ for: o.id }), o.label),\n    control, after, helpP(t, o.id, o.help), errP(t, o.id, o.err));\n}\n\nfunction group(t: Th, o: { name: string; legend: string; type: \"radio\" | \"checkbox\"; opts: Opt[]; req?: boolean; help?: string; err?: string; span?: boolean; row?: boolean; checked?: string }): El {\n  return h(\"fieldset\", `min-w-0 ${o.span ? \"sm:col-span-2\" : \"\"}`.trim(), o.span ? \"f-fieldset f-span\" : \"f-fieldset\",\n    h(\"legend\", `mb-2 text-sm font-medium ${t.label}`, \"f-legend\", o.legend),\n    h(\"div\", o.row ? \"flex flex-wrap gap-x-5 gap-y-2\" : \"grid gap-2\", o.row ? \"f-options f-row\" : \"f-options\",\n      ...o.opts.map(([v, l]) => {\n        const id = `${o.name}-${v}`;\n        const a: Attrs = { type: o.type, id, name: o.name, value: v };\n        if (o.req) a.required = \"\";\n        if (o.checked === v) a.checked = \"\";\n        if (o.help) a[\"aria-describedby\"] = `${o.name}-help`;\n        return h(\"div\", \"flex min-h-[32px] items-center gap-2.5\", \"f-check\",\n          h(\"input\", t.check, \"\", $(a)),\n          h(\"label\", `cursor-pointer text-[15px] ${t.label}`, \"\", $({ for: id }), l));\n      })),\n    helpP(t, o.name, o.help), errP(t, o.name, o.err));\n}\n\nfunction single(t: Th, o: { id: string; label: string; a?: Attrs; err?: string; help?: string; sw?: boolean; span?: boolean }): El {\n  const a: Attrs = { type: \"checkbox\", id: o.id, name: o.id, ...describe(o.id, o.help), ...(o.a ?? {}) };\n  if (o.sw) a.role = \"switch\";\n  const cls = o.sw\n    ? `relative h-6 w-10 shrink-0 cursor-pointer appearance-none rounded-full transition before:absolute before:left-[3px] before:top-[3px] before:h-[18px] before:w-[18px] before:rounded-full before:bg-white before:transition before:content-[''] checked:before:translate-x-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 ${t.sw}`\n    : t.check;\n  return h(\"div\", `${o.span ? \"sm:col-span-2 \" : \"\"}flex flex-col gap-1`, o.span ? \"f-field f-span\" : \"f-field\",\n    h(\"div\", o.sw ? \"flex min-h-[40px] items-center justify-between gap-4\" : \"flex items-start gap-2.5\", o.sw ? \"f-check f-between\" : \"f-check\",\n      o.sw ? null : h(\"input\", `${cls} mt-0.5`, \"\", $(a)),\n      h(\"label\", `cursor-pointer text-[15px] leading-6 ${t.label}`, \"\", $({ for: o.id }), o.label),\n      o.sw ? h(\"input\", cls, \"f-switch\", $(a)) : null),\n    helpP(t, o.id, o.help), errP(t, o.id, o.err));\n}\n\nfunction range(t: Th, o: { id: string; label: string; min: string; max: string; step: string; value: string; unit: string; help?: string; span?: boolean }): El {\n  return h(\"div\", `flex flex-col gap-2 ${o.span ? \"sm:col-span-2\" : \"\"}`.trim(), o.span ? \"f-field f-span\" : \"f-field\",\n    h(\"div\", \"flex items-baseline justify-between gap-3\", \"f-between\",\n      h(\"label\", `text-sm font-medium ${t.label}`, \"f-label\", $({ for: o.id }), o.label),\n      h(\"output\", `text-sm font-bold tabular-nums ${t.label}`, \"f-output\", $({ for: o.id, id: `${o.id}-out`, \"data-unit\": o.unit }), `${o.value}${o.unit}`)),\n    h(\"input\", t.range, \"f-range\", $({ type: \"range\", id: o.id, name: o.id, min: o.min, max: o.max, step: o.step, value: o.value, ...describe(o.id, o.help) })),\n    helpP(t, o.id, o.help));\n}\n\nconst hidden = (name: string, value: string) => h(\"input\", \"\", \"\", $({ type: \"hidden\", name, value }));\n\nfunction actions(t: Th, list: [string, string][]): El {\n  return h(\"div\", \"mt-6 flex flex-wrap items-center gap-3\", \"f-actions\",\n    ...list.map(([type, label], i) => h(\"button\", `${t.btnBase} ${i === 0 ? t.btn : t.btn2}`, i === 0 ? \"f-btn\" : \"f-btn f-btn2\",\n      $({ type, ...(type === \"button\" ? { \"data-reveal\": \"\", \"aria-pressed\": \"false\" } : {}) }), label)));\n}\n\nfunction form(t: Th, o: { id: string; biz: string; title: string; lead: string; kids: Kid[]; acts: El; enctype?: boolean; narrow?: boolean }): El {\n  const fa: Attrs = { id: o.id, action: \"#\", method: \"post\", novalidate: \"\" };\n  if (o.enctype) fa.enctype = \"multipart/form-data\";\n  return h(\"div\", `${t.wrap} px-4 py-8 sm:px-8 sm:py-10`, \"f-wrap\",\n    h(\"form\", `mx-auto ${o.narrow ? \"max-w-md\" : \"max-w-xl\"} ${t.card} p-6 sm:p-8`, o.narrow ? \"f-card f-narrow\" : \"f-card\", $(fa),\n      h(\"p\", `text-xs font-semibold uppercase tracking-[0.14em] ${t.eyebrow}`, \"f-eyebrow\", o.biz),\n      h(\"h3\", `mt-2 text-2xl font-semibold tracking-tight ${t.title}`, \"f-title\", o.title),\n      h(\"p\", `mt-1.5 text-sm leading-6 ${t.muted}`, \"f-lead\", o.lead),\n      h(\"div\", `mt-6 grid gap-4 ${o.narrow ? \"\" : \"sm:grid-cols-2\"}`.trim(), o.narrow ? \"f-grid f-one\" : \"f-grid\", ...o.kids),\n      o.acts,\n      h(\"p\", `mt-4 text-sm font-medium empty:hidden ${t.stat}`, \"f-status\", $({ role: \"status\", \"aria-live\": \"polite\" }))));\n}\n\n/* ---------- the 15 forms ---------- */\nconst FAMILIES = { contact: \"Contact\", account: \"Account\", commerce: \"Checkout\", booking: \"Booking\", data: \"Survey and data\" } as const;\ntype Family = keyof typeof FAMILIES;\ntype Item = { f: Family; name: string; theme: Th; types: string[]; node: El };\nconst ITEMS: Item[] = [];\nconst add = (f: Family, name: string, theme: Th, types: string[], node: El) => ITEMS.push({ f, name, theme, types, node });\n\n{\n  const t = T.stone;\n  add(\"contact\", \"Studio contact form\", t, [\"text\", \"email\", \"tel\", \"select\", \"textarea\", \"checkbox\", \"submit\"], form(t, {\n    id: \"contact-form\", biz: \"Hollis & Wren Architects\", title: \"Start a conversation\", lead: \"Tell us about the site and what you have in mind. One of the partners replies within two working days.\",\n    kids: [\n      field(t, { id: \"cf-name\", label: \"Full name\", a: { autocomplete: \"name\", required: \"\" }, err: \"Please tell us your name.\" }),\n      field(t, { id: \"cf-email\", label: \"Email\", type: \"email\", a: { autocomplete: \"email\", required: \"\" }, err: \"Enter an email like name@example.com.\" }),\n      field(t, { id: \"cf-phone\", label: \"Phone (optional)\", type: \"tel\", a: { autocomplete: \"tel\", pattern: \"[0-9 +()-]{7,20}\" }, help: \"Digits, spaces and + only.\", err: \"That does not look like a phone number.\" }),\n      field(t, { id: \"cf-type\", label: \"Project type\", tag: \"select\", a: { required: \"\" }, opts: [[\"extension\", \"Extension\"], [\"new-build\", \"New build\"], [\"renovation\", \"Renovation\"], [\"commercial\", \"Commercial fit-out\"]], err: \"Pick the closest project type.\" }),\n      field(t, { id: \"cf-msg\", label: \"About the project\", tag: \"textarea\", span: true, a: { minlength: \"20\", maxlength: \"1200\", required: \"\" }, help: \"Budget, timing and anything unusual about the plot. At least 20 characters.\", err: \"A few more words, please: at least 20 characters.\" }),\n      single(t, { id: \"cf-consent\", label: \"I agree to be contacted about this enquiry.\", span: true, a: { required: \"\" }, err: \"We need your agreement before we can reply.\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Send enquiry\"]]),\n  }));\n}\n{\n  const t = T.tide;\n  add(\"contact\", \"Newsletter signup\", t, [\"email\", \"radio\", \"hidden\", \"submit\"], form(t, {\n    id: \"newsletter-form\", narrow: true, biz: \"The Low Tide Letter\", title: \"Coastal notes, by post and by email\", lead: \"Tide tables, walking routes and one long read about the shoreline. Unsubscribe from any issue.\",\n    kids: [\n      hidden(\"source\", \"footer-signup\"),\n      field(t, { id: \"nl-email\", label: \"Email address\", type: \"email\", a: { autocomplete: \"email\", required: \"\", placeholder: \"you@example.com\" }, err: \"Enter a valid email address.\" }),\n      group(t, { name: \"nl-freq\", legend: \"How often?\", type: \"radio\", row: true, req: true, checked: \"weekly\", opts: [[\"weekly\", \"Weekly\"], [\"monthly\", \"Monthly digest\"]] }),\n    ],\n    acts: actions(t, [[\"submit\", \"Subscribe\"]]),\n  }));\n}\n{\n  const t = T.violet;\n  add(\"account\", \"Create account\", t, [\"text\", \"email\", \"password\", \"url\", \"checkbox\", \"submit\"], form(t, {\n    id: \"signup-form\", biz: \"Brightloom\", title: \"Create your studio account\", lead: \"Free for one project. Upgrade when your client signs off.\",\n    kids: [\n      field(t, { id: \"su-user\", label: \"Username\", a: { autocomplete: \"username\", required: \"\", pattern: \"[a-z0-9_]{3,20}\", minlength: \"3\", maxlength: \"20\" }, help: \"3 to 20 lowercase letters, numbers or underscores.\", err: \"Use 3 to 20 lowercase letters, numbers or underscores.\" }),\n      field(t, { id: \"su-email\", label: \"Work email\", type: \"email\", a: { autocomplete: \"email\", required: \"\" }, err: \"Enter a valid email address.\" }),\n      field(t, { id: \"su-pass\", label: \"Password\", type: \"password\", span: true, a: { autocomplete: \"new-password\", required: \"\", minlength: \"10\" }, help: \"At least 10 characters. A short sentence works well.\", err: \"Your password needs at least 10 characters.\" }),\n      field(t, { id: \"su-site\", label: \"Portfolio link (optional)\", type: \"url\", span: true, a: { autocomplete: \"url\" }, help: \"Include the https part at the start.\", err: \"Enter a full address that starts with https.\" }),\n      single(t, { id: \"su-terms\", label: \"I accept the terms of service and privacy policy.\", span: true, a: { required: \"\" }, err: \"Tick this box to create an account.\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Create account\"]]),\n  }));\n}\n{\n  const t = T.quarry;\n  add(\"account\", \"Sign in\", t, [\"email\", \"password\", \"checkbox\", \"button\", \"submit\"], form(t, {\n    id: \"login-form\", narrow: true, biz: \"Quarry Ledger\", title: \"Sign in to your books\", lead: \"Use the email you registered with.\",\n    kids: [\n      field(t, { id: \"li-email\", label: \"Email\", type: \"email\", a: { autocomplete: \"email\", required: \"\" }, err: \"Enter the email you signed up with.\" }),\n      field(t, { id: \"li-pass\", label: \"Password\", type: \"password\", a: { autocomplete: \"current-password\", required: \"\" }, err: \"Enter your password.\" }),\n      single(t, { id: \"li-keep\", label: \"Keep me signed in on this device\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Sign in\"], [\"button\", \"Show password\"]]),\n  }));\n}\n{\n  const t = T.roast;\n  add(\"commerce\", \"Card payment\", t, [\"text\", \"month\", \"number\", \"hidden\", \"submit\"], form(t, {\n    id: \"payment-form\", biz: \"Saltmarsh Coffee Roasters\", title: \"Pay for your subscription\", lead: \"Two bags of whole bean coffee every month. You can pause or skip from your account.\",\n    kids: [\n      hidden(\"order\", \"SCR-20418\"),\n      field(t, { id: \"pay-name\", label: \"Name on card\", span: true, a: { autocomplete: \"cc-name\", required: \"\" }, err: \"Enter the name printed on the card.\" }),\n      field(t, { id: \"pay-card\", label: \"Card number\", span: true, a: { autocomplete: \"cc-number\", inputmode: \"numeric\", pattern: \"[0-9 ]{13,23}\", required: \"\", placeholder: \"1234 5678 9012 3456\" }, help: \"Typed as text, not number, so leading zeros and spaces survive.\", err: \"Card numbers are 13 to 19 digits.\" }),\n      field(t, { id: \"pay-exp\", label: \"Expiry\", type: \"month\", a: { autocomplete: \"cc-exp\", min: \"2026-10\", required: \"\" }, err: \"Choose an expiry month that has not passed.\" }),\n      field(t, { id: \"pay-cvc\", label: \"Security code\", a: { autocomplete: \"cc-csc\", inputmode: \"numeric\", pattern: \"[0-9]{3,4}\", required: \"\" }, help: \"3 or 4 digits on the back.\", err: \"Enter the 3 or 4 digit code.\" }),\n      field(t, { id: \"pay-bags\", label: \"Bags per month\", type: \"number\", a: { min: \"1\", max: \"6\", step: \"1\", value: \"2\", required: \"\" }, help: \"1 to 6 bags at $19 each.\", err: \"Choose between 1 and 6 bags.\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Pay $38.00\"]]),\n  }));\n}\n{\n  const t = T.field;\n  add(\"commerce\", \"Shipping address\", t, [\"text\", \"datalist\", \"tel\", \"checkbox\", \"submit\"], form(t, {\n    id: \"shipping-form\", biz: \"Fieldnote Supply Co.\", title: \"Where should we send it?\", lead: \"Notebooks ship in two working days from our warehouse.\",\n    kids: [\n      field(t, { id: \"sh-name\", label: \"Recipient\", span: true, a: { autocomplete: \"shipping name\", required: \"\" }, err: \"Who should the parcel be addressed to?\" }),\n      field(t, { id: \"sh-line1\", label: \"Street address\", span: true, a: { autocomplete: \"shipping address-line1\", required: \"\" }, err: \"Enter the street and house number.\" }),\n      field(t, { id: \"sh-city\", label: \"Town or city\", a: { autocomplete: \"shipping address-level2\", required: \"\" }, err: \"Enter a town or city.\" }),\n      field(t, { id: \"sh-post\", label: \"Postal code\", a: { autocomplete: \"shipping postal-code\", required: \"\", pattern: \"[A-Za-z0-9 -]{3,10}\" }, err: \"Check the postal code.\" }),\n      field(t, { id: \"sh-country\", label: \"Country\", a: { autocomplete: \"shipping country-name\", required: \"\" }, list: [\"Australia\", \"Canada\", \"Ireland\", \"New Zealand\", \"United Kingdom\", \"United States\"], help: \"Start typing to see suggestions.\", err: \"Enter the country.\" }),\n      field(t, { id: \"sh-tel\", label: \"Phone for the courier\", type: \"tel\", a: { autocomplete: \"tel\", required: \"\" }, err: \"The courier needs a phone number.\" }),\n      single(t, { id: \"sh-same\", label: \"Use this as my billing address too\", span: true, a: { checked: \"\" } }),\n    ],\n    acts: actions(t, [[\"submit\", \"Continue to payment\"]]),\n  }));\n}\n{\n  const t = T.rose;\n  add(\"data\", \"Customer feedback survey\", t, [\"radio\", \"range\", \"output\", \"checkbox\", \"textarea\", \"submit\"], form(t, {\n    id: \"survey-form\", biz: \"Kettle & Crumb Bakery\", title: \"How was your visit?\", lead: \"Three quick questions. Every answer goes straight to the bakers.\",\n    kids: [\n      group(t, { name: \"sv-rating\", legend: \"Overall, how did we do?\", type: \"radio\", row: true, req: true, span: true, opts: [[\"1\", \"Poor\"], [\"2\", \"Fair\"], [\"3\", \"Good\"], [\"4\", \"Great\"], [\"5\", \"Loved it\"]], err: \"Pick one rating.\" }),\n      range(t, { id: \"sv-wait\", label: \"How long did you wait?\", min: \"0\", max: \"30\", step: \"1\", value: \"6\", unit: \" min\", span: true, help: \"Drag the slider; the number updates as you go.\" }),\n      group(t, { name: \"sv-bought\", legend: \"What did you buy?\", type: \"checkbox\", span: true, row: true, opts: [[\"bread\", \"Bread\"], [\"pastry\", \"Pastry\"], [\"cake\", \"Cake\"], [\"coffee\", \"Coffee\"]] }),\n      field(t, { id: \"sv-note\", label: \"Anything we should change?\", tag: \"textarea\", span: true, a: { maxlength: \"600\" }, help: \"Optional, up to 600 characters.\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Send feedback\"]]),\n  }));\n}\n{\n  const t = T.beam;\n  add(\"data\", \"Job application\", t, [\"text\", \"email\", \"url\", \"select\", \"number\", \"file\", \"textarea\", \"submit\"], form(t, {\n    id: \"job-form\", enctype: true, biz: \"Northbeam Labs\", title: \"Apply: Frontend Engineer\", lead: \"Remote within two hours of UTC. We read every application in full.\",\n    kids: [\n      field(t, { id: \"job-name\", label: \"Full name\", a: { autocomplete: \"name\", required: \"\" }, err: \"Enter your name.\" }),\n      field(t, { id: \"job-email\", label: \"Email\", type: \"email\", a: { autocomplete: \"email\", required: \"\" }, err: \"Enter a valid email address.\" }),\n      field(t, { id: \"job-link\", label: \"Portfolio or code samples\", type: \"url\", a: { required: \"\" }, err: \"Add a full link that starts with https.\" }),\n      field(t, { id: \"job-years\", label: \"Years of experience\", type: \"number\", a: { min: \"0\", max: \"40\", required: \"\" }, err: \"Enter a number from 0 to 40.\" }),\n      field(t, { id: \"job-level\", label: \"Level\", tag: \"select\", span: true, a: { required: \"\" }, opts: [[\"mid\", \"Mid-level\"], [\"senior\", \"Senior\"], [\"staff\", \"Staff\"]], err: \"Choose the level you are applying for.\" }),\n      field(t, { id: \"job-cv\", label: \"CV\", type: \"file\", span: true, a: { accept: \".pdf,.doc,.docx\", required: \"\" }, help: \"PDF or Word document.\", err: \"Attach your CV as a PDF or Word file.\" }),\n      field(t, { id: \"job-why\", label: \"Why this role?\", tag: \"textarea\", span: true, a: { minlength: \"50\", required: \"\" }, help: \"A short paragraph is plenty: at least 50 characters.\", err: \"Write at least 50 characters.\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Submit application\"]]),\n  }));\n}\n{\n  const t = T.sky;\n  add(\"booking\", \"Appointment booking\", t, [\"date\", \"time\", \"select\", \"radio\", \"tel\", \"submit\"], form(t, {\n    id: \"booking-form\", biz: \"Cedar Row Physio\", title: \"Book an appointment\", lead: \"Clinic hours are 8:00 to 18:00, Monday to Saturday.\",\n    kids: [\n      field(t, { id: \"bk-date\", label: \"Date\", type: \"date\", a: { min: \"2026-10-14\", max: \"2026-12-23\", required: \"\" }, help: \"Bookings open up to 10 weeks ahead.\", err: \"Choose a date between 14 Oct and 23 Dec.\" }),\n      field(t, { id: \"bk-time\", label: \"Time\", type: \"time\", a: { min: \"08:00\", max: \"17:15\", step: \"900\", required: \"\" }, help: \"Quarter-hour slots.\", err: \"Pick a time between 08:00 and 17:15.\" }),\n      field(t, { id: \"bk-who\", label: \"Physiotherapist\", tag: \"select\", a: { required: \"\" }, opts: [[\"any\", \"First available\"], [\"ines\", \"Ines Moreau\"], [\"dev\", \"Dev Rathore\"], [\"kate\", \"Kate Okafor\"]], err: \"Choose who you would like to see.\" }),\n      field(t, { id: \"bk-tel\", label: \"Mobile for reminders\", type: \"tel\", a: { autocomplete: \"tel\", required: \"\" }, err: \"Add a number for your text reminder.\" }),\n      group(t, { name: \"bk-kind\", legend: \"Appointment\", type: \"radio\", span: true, req: true, checked: \"new\", opts: [[\"new\", \"New patient assessment, 45 min\"], [\"follow\", \"Follow-up, 30 min\"]] }),\n    ],\n    acts: actions(t, [[\"submit\", \"Request booking\"]]),\n  }));\n}\n{\n  const t = T.plum;\n  add(\"booking\", \"Supper club RSVP\", t, [\"text\", \"email\", \"radio\", \"number\", \"datetime-local\", \"select\", \"submit\"], form(t, {\n    id: \"rsvp-form\", biz: \"Marigold Hall\", title: \"Harvest supper, RSVP\", lead: \"Seven courses at one long table. Doors open at seven on Saturday 15 November.\",\n    kids: [\n      field(t, { id: \"rs-name\", label: \"Your name\", a: { autocomplete: \"name\", required: \"\" }, err: \"Tell us who is coming.\" }),\n      field(t, { id: \"rs-email\", label: \"Email\", type: \"email\", a: { autocomplete: \"email\", required: \"\" }, err: \"Enter an email for your ticket.\" }),\n      group(t, { name: \"rs-coming\", legend: \"Will you join us?\", type: \"radio\", row: true, req: true, span: true, opts: [[\"yes\", \"Joyfully, yes\"], [\"no\", \"Sadly, no\"]], err: \"Let us know either way.\" }),\n      field(t, { id: \"rs-guests\", label: \"Extra guests\", type: \"number\", a: { min: \"0\", max: \"3\", value: \"0\" }, help: \"Up to 3.\", err: \"You can bring up to 3 guests.\" }),\n      field(t, { id: \"rs-arrive\", label: \"Arriving around\", type: \"datetime-local\", a: { min: \"2026-11-15T18:30\", max: \"2026-11-15T21:00\", value: \"2026-11-15T19:00\" }, err: \"Pick a time on the night, 18:30 to 21:00.\" }),\n      field(t, { id: \"rs-diet\", label: \"Dietary needs\", tag: \"select\", span: true, opts: [[\"none\", \"None\"], [\"veg\", \"Vegetarian\"], [\"vegan\", \"Vegan\"], [\"gf\", \"Gluten free\"], [\"other\", \"Something else, we will email\"]] }),\n    ],\n    acts: actions(t, [[\"submit\", \"Send RSVP\"]]),\n  }));\n}\n{\n  const t = T.harbour;\n  add(\"data\", \"Property search filters\", t, [\"search\", \"datalist\", \"number\", \"checkbox\", \"reset\", \"submit\"], form(t, {\n    id: \"search-form\", biz: \"Harbour Lettings\", title: \"Find a place to rent\", lead: \"214 homes across the waterfront districts.\",\n    kids: [\n      field(t, { id: \"ps-q\", label: \"Search\", type: \"search\", span: true, a: { placeholder: \"Street, school or postcode\", name: \"q\" } }),\n      field(t, { id: \"ps-area\", label: \"Neighbourhood\", span: true, list: [\"Old Harbour\", \"Chandlers Quay\", \"Ropewalk\", \"North Basin\", \"Lighthouse Hill\"] }),\n      field(t, { id: \"ps-min\", label: \"Min rent per month\", type: \"number\", a: { min: \"500\", max: \"6000\", step: \"50\", placeholder: \"500\" }, err: \"Between 500 and 6,000.\" }),\n      field(t, { id: \"ps-max\", label: \"Max rent per month\", type: \"number\", a: { min: \"500\", max: \"6000\", step: \"50\", placeholder: \"2500\" }, err: \"Between 500 and 6,000.\" }),\n      group(t, { name: \"ps-feat\", legend: \"Must have\", type: \"checkbox\", row: true, span: true, opts: [[\"pets\", \"Pets allowed\"], [\"parking\", \"Parking\"], [\"garden\", \"Garden\"], [\"furnished\", \"Furnished\"]] }),\n    ],\n    acts: actions(t, [[\"submit\", \"Show homes\"], [\"reset\", \"Clear filters\"]]),\n  }));\n}\n{\n  const t = T.pine;\n  add(\"account\", \"Settings and preferences\", t, [\"color\", \"checkbox switch\", \"range\", \"output\", \"radio\", \"select\", \"reset\", \"submit\"], form(t, {\n    id: \"settings-form\", biz: \"Pinecone Notes\", title: \"Workspace preferences\", lead: \"Changes apply to every device signed in to this workspace.\",\n    kids: [\n      field(t, { id: \"st-accent\", label: \"Accent colour\", type: \"color\", a: { value: \"#2dd4bf\" }, help: \"Used for links and highlights.\" }),\n      field(t, { id: \"st-lang\", label: \"Language\", tag: \"select\", opts: [[\"en\", \"English\"], [\"es\", \"Espanol\"], [\"fr\", \"Francais\"], [\"de\", \"Deutsch\"]] }),\n      range(t, { id: \"st-size\", label: \"Editor text size\", min: \"12\", max: \"22\", step: \"1\", value: \"16\", unit: \"px\", span: true }),\n      group(t, { name: \"st-theme\", legend: \"Theme\", type: \"radio\", row: true, span: true, checked: \"system\", opts: [[\"light\", \"Light\"], [\"dark\", \"Dark\"], [\"system\", \"Match system\"]] }),\n      single(t, { id: \"st-digest\", label: \"Weekly digest email\", sw: true, span: true, a: { checked: \"\" } }),\n      single(t, { id: \"st-sound\", label: \"Sound when a note syncs\", sw: true, span: true }),\n    ],\n    acts: actions(t, [[\"submit\", \"Save preferences\"], [\"reset\", \"Reset\"]]),\n  }));\n}\n{\n  const t = T.grid;\n  add(\"contact\", \"Support ticket\", t, [\"email\", \"text\", \"select\", \"url\", \"file\", \"textarea\", \"submit\"], form(t, {\n    id: \"ticket-form\", enctype: true, biz: \"Gridline Hosting\", title: \"Open a support ticket\", lead: \"Urgent tickets are answered around the clock. Everything else within one business day.\",\n    kids: [\n      field(t, { id: \"tk-email\", label: \"Account email\", type: \"email\", a: { autocomplete: \"email\", required: \"\" }, err: \"Enter the email on your account.\" }),\n      field(t, { id: \"tk-prio\", label: \"Priority\", tag: \"select\", a: { required: \"\" }, opts: [[\"low\", \"Low: a question\"], [\"normal\", \"Normal: something is off\"], [\"urgent\", \"Urgent: site is down\"]], err: \"Choose a priority.\" }),\n      field(t, { id: \"tk-subject\", label: \"Subject\", span: true, a: { required: \"\", maxlength: \"90\" }, err: \"Add a short subject.\" }),\n      field(t, { id: \"tk-url\", label: \"Affected address\", type: \"url\", span: true, a: {}, help: \"The page where you saw the problem.\", err: \"Paste the full address, including the https part.\" }),\n      field(t, { id: \"tk-body\", label: \"What happened?\", tag: \"textarea\", span: true, a: { required: \"\", minlength: \"30\" }, help: \"What you expected, what you saw, and when it started.\", err: \"Please add a little more detail: at least 30 characters.\" }),\n      field(t, { id: \"tk-shots\", label: \"Screenshots\", type: \"file\", span: true, a: { accept: \"image/*\", multiple: \"\" }, help: \"Optional. PNG or JPG, several allowed.\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Open ticket\"]]),\n  }));\n}\n{\n  const t = T.brick;\n  add(\"commerce\", \"Quote request\", t, [\"text\", \"tel\", \"select\", \"week\", \"number\", \"radio\", \"hidden\", \"textarea\", \"submit\"], form(t, {\n    id: \"quote-form\", biz: \"Brickfield Roofing\", title: \"Get a roofing quote\", lead: \"Free survey within 20 miles. Written quote within three days of the visit.\",\n    kids: [\n      hidden(\"form-name\", \"quote\"),\n      field(t, { id: \"qt-name\", label: \"Name\", a: { autocomplete: \"name\", required: \"\" }, err: \"Enter your name.\" }),\n      field(t, { id: \"qt-tel\", label: \"Phone\", type: \"tel\", a: { autocomplete: \"tel\", required: \"\" }, err: \"Enter a phone number.\" }),\n      field(t, { id: \"qt-job\", label: \"Type of job\", tag: \"select\", a: { required: \"\" }, opts: [[\"repair\", \"Repair or leak\"], [\"reroof\", \"Full re-roof\"], [\"flat\", \"Flat roof\"], [\"gutters\", \"Gutters and fascias\"]], err: \"Choose a job type.\" }),\n      field(t, { id: \"qt-week\", label: \"Preferred start week\", type: \"week\", a: { min: \"2026-W43\" }, help: \"Pick any week from late October.\", err: \"Choose a week from W43 onwards.\" }),\n      field(t, { id: \"qt-area\", label: \"Roof area (sq m, rough)\", type: \"number\", a: { min: \"5\", max: \"1000\", step: \"5\" }, err: \"Between 5 and 1,000 square metres.\" }),\n      group(t, { name: \"qt-storeys\", legend: \"Storeys\", type: \"radio\", row: true, checked: \"2\", opts: [[\"1\", \"1\"], [\"2\", \"2\"], [\"3\", \"3+\"]] }),\n      field(t, { id: \"qt-notes\", label: \"Anything else?\", tag: \"textarea\", span: true }),\n    ],\n    acts: actions(t, [[\"submit\", \"Request my quote\"]]),\n  }));\n}\n{\n  const t = T.lumen;\n  add(\"account\", \"Password reset\", t, [\"email\", \"text\", \"password\", \"submit\"], form(t, {\n    id: \"reset-form\", narrow: true, biz: \"Lumen Savings\", title: \"Choose a new password\", lead: \"We sent a 6 digit code to your email. It expires in 15 minutes.\",\n    kids: [\n      field(t, { id: \"rp-email\", label: \"Email\", type: \"email\", a: { autocomplete: \"email\", required: \"\" }, err: \"Enter your email.\" }),\n      field(t, { id: \"rp-code\", label: \"6 digit code\", a: { autocomplete: \"one-time-code\", inputmode: \"numeric\", pattern: \"[0-9]{6}\", maxlength: \"6\", required: \"\" }, err: \"The code is exactly 6 digits.\" }),\n      field(t, { id: \"rp-new\", label: \"New password\", type: \"password\", a: { autocomplete: \"new-password\", minlength: \"12\", required: \"\" }, help: \"At least 12 characters.\", err: \"Use at least 12 characters.\" }),\n    ],\n    acts: actions(t, [[\"submit\", \"Update password\"]]),\n  }));\n}\n\n/* ---------- serialisers ---------- */\nconst VOID = new Set([\"input\", \"br\", \"hr\", \"img\"]);\nconst JSX_ATTR: Record<string, string> = {\n  for: \"htmlFor\", autocomplete: \"autoComplete\", minlength: \"minLength\", maxlength: \"maxLength\", inputmode: \"inputMode\",\n  novalidate: \"noValidate\", enctype: \"encType\", tabindex: \"tabIndex\", readonly: \"readOnly\",\n};\nconst BOOL = new Set([\"required\", \"novalidate\", \"multiple\", \"checked\", \"hidden\"]);\nconst escHtml = (s: string) => s.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n\nfunction toReact(n: N, key: string | number): ReactNode {\n  if (typeof n === \"string\") return n;\n  const props: Record<string, unknown> = { key };\n  if (n.c) props.className = n.c;\n  for (const [k, v] of Object.entries(n.a ?? {})) {\n    if (k === \"checked\") props.defaultChecked = true;\n    else if (k === \"value\" && (n.t === \"input\" && n.a?.type !== \"hidden\" && n.a?.type !== \"button\" && n.a?.type !== \"reset\")) props.defaultValue = v;\n    else props[JSX_ATTR[k] ?? k] = BOOL.has(k) ? true : v;\n  }\n  return createElement(n.t, props, ...(VOID.has(n.t) || n.t === \"textarea\" ? [] : n.k.map((k, i) => toReact(k, i))));\n}\n\nfunction serial(n: N, mode: \"css\" | \"tw\", depth: number): string {\n  const pad = \"  \".repeat(depth);\n  if (typeof n === \"string\") return pad + escHtml(n);\n  const attrs: string[] = [];\n  const cls = mode === \"tw\" ? n.c : n.s;\n  if (cls) attrs.push(`class=\"${cls}\"`);\n  for (const [k, v] of Object.entries(n.a ?? {})) attrs.push(BOOL.has(k) ? k : `${k}=\"${v}\"`);\n  const open = `<${n.t}${attrs.length ? \" \" + attrs.join(\" \") : \"\"}`;\n  if (VOID.has(n.t)) return `${pad}${open}>`;\n  if (n.k.every((k) => typeof k === \"string\")) return `${pad}${open}>${n.k.map((k) => serial(k, mode, 0)).join(\"\")}</${n.t}>`;\n  return `${pad}${open}>\\n${n.k.map((k) => serial(k, mode, depth + 1)).join(\"\\n\")}\\n${pad}</${n.t}>`;\n}\n\nfunction cssFor(th: Th): string {\n  const c = th.css;\n  return `<style>\n  .f-wrap { background: ${c.bg}; color: ${c.text}; padding: 40px 16px; font-family: ${c.font}; }\n  .f-card { max-width: 576px; margin: 0 auto; padding: 28px; background: ${c.card}; border: 1px solid ${c.border}; border-radius: ${c.r}; }\n  .f-narrow { max-width: 448px; }\n  .f-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: ${c.accent}; }\n  .f-title { margin: 8px 0 0; font-size: 24px; line-height: 1.2; }\n  .f-lead, .f-help { margin: 6px 0 0; color: ${c.muted}; font-size: 14px; line-height: 1.5; }\n  .f-help { margin: 0; font-size: 13px; }\n  .f-grid { display: grid; gap: 16px; margin-top: 24px; }\n  @media (min-width: 640px) { .f-grid:not(.f-one) { grid-template-columns: 1fr 1fr; } .f-span { grid-column: 1 / -1; } }\n  .f-field, .f-fieldset { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }\n  .f-label, .f-legend { font-size: 14px; font-weight: 600; padding: 0; }\n  .f-input { min-height: 44px; padding: 8px 12px; font: inherit; font-size: 15px; color: inherit; background: ${c.input}; border: 1px solid ${c.border}; border-radius: ${c.r2}; }\n  .f-input:focus, .f-color:focus, .f-file:focus-visible, .f-check input:focus-visible { outline: 3px solid ${c.accent}; outline-offset: 1px; }\n  .f-input[aria-invalid=\"true\"] { border-color: ${c.err}; }\n  .f-error { margin: 0; font-size: 13px; font-weight: 600; color: ${c.err}; }\n  .f-options { display: grid; gap: 8px; }\n  .f-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }\n  .f-check { display: flex; align-items: center; gap: 10px; min-height: 32px; }\n  .f-check input[type=\"checkbox\"]:not(.f-switch), .f-check input[type=\"radio\"] { width: 18px; height: 18px; accent-color: ${c.accent}; }\n  .f-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n  .f-range { width: 100%; accent-color: ${c.accent}; }\n  .f-output { font-weight: 700; font-variant-numeric: tabular-nums; }\n  .f-color { width: 80px; height: 44px; padding: 4px; background: transparent; border: 1px solid ${c.border}; border-radius: 6px; }\n  .f-switch { appearance: none; position: relative; flex-shrink: 0; width: 40px; height: 24px; margin: 0; border-radius: 999px; background: ${c.border}; cursor: pointer; }\n  .f-switch::before { content: \"\"; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }\n  .f-switch:checked { background: ${c.accent}; }\n  .f-switch:checked::before { transform: translateX(16px); }\n  .f-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }\n  .f-btn { min-height: 44px; padding: 0 20px; font: inherit; font-size: 14px; font-weight: 600; color: ${c.on}; background: ${c.accent}; border: 1px solid ${c.accent}; border-radius: ${c.r2}; cursor: pointer; }\n  .f-btn2 { color: inherit; background: transparent; border-color: ${c.border}; }\n  .f-status { margin: 16px 0 0; font-size: 14px; font-weight: 600; }\n  .f-status:empty { display: none; }\n  .f-status[data-state=\"ok\"] { color: ${c.ok}; }\n  .f-status[data-state=\"error\"] { color: ${c.err}; }\n  [hidden] { display: none !important; }\n</style>`;\n}\n\nconst SCRIPT = `<script>\n  // Demo behaviour: checks every field with the browser's own rules, shows the\n  // matching error text and a status line. Nothing is sent while action=\"#\".\n  document.querySelectorAll(\"form[novalidate]\").forEach(function (form) {\n    var status = form.querySelector(\"[role=status]\");\n    form.addEventListener(\"submit\", function (event) {\n      event.preventDefault();\n      var firstBad = null;\n      Array.prototype.forEach.call(form.elements, function (el) {\n        if (!el.willValidate) return;\n        var key = el.type === \"radio\" || (el.type === \"checkbox\" && !el.id) ? el.name : el.id;\n        var err = document.getElementById(key + \"-err\");\n        var bad = !el.checkValidity();\n        if (bad) el.setAttribute(\"aria-invalid\", \"true\"); else el.removeAttribute(\"aria-invalid\");\n        if (err) {\n          err.hidden = !bad;\n          var ids = (el.getAttribute(\"aria-describedby\") || \"\").split(\" \").filter(function (id) { return id && id !== err.id; });\n          if (bad) ids.push(err.id);\n          if (ids.length) el.setAttribute(\"aria-describedby\", ids.join(\" \")); else el.removeAttribute(\"aria-describedby\");\n        }\n        if (bad && !firstBad) firstBad = el;\n      });\n      if (firstBad) {\n        status.dataset.state = \"error\";\n        status.textContent = \"Please fix the highlighted fields.\";\n        firstBad.focus();\n        return;\n      }\n      status.dataset.state = \"ok\";\n      status.textContent = \"Thanks, that all checks out.\";\n      if (form.getAttribute(\"action\") !== \"#\") form.submit();\n    });\n    form.addEventListener(\"reset\", function () {\n      form.querySelectorAll(\"[aria-invalid]\").forEach(function (el) { el.removeAttribute(\"aria-invalid\"); });\n      form.querySelectorAll(\".f-error, [id$='-err']\").forEach(function (el) { el.hidden = true; });\n      status.textContent = \"\";\n      setTimeout(function () { form.querySelectorAll(\"output\").forEach(sync); });\n    });\n    form.addEventListener(\"input\", function (event) {\n      if (event.target.type === \"range\") form.querySelectorAll(\"output\").forEach(sync);\n    });\n    form.querySelectorAll(\"[data-reveal]\").forEach(function (button) {\n      button.addEventListener(\"click\", function () {\n        var pw = form.querySelector(\"input[autocomplete=current-password]\");\n        var show = pw.type === \"password\";\n        pw.type = show ? \"text\" : \"password\";\n        button.setAttribute(\"aria-pressed\", String(show));\n        button.textContent = show ? \"Hide password\" : \"Show password\";\n      });\n    });\n  });\n  function sync(out) {\n    var input = document.getElementById(out.htmlFor.value);\n    if (input) out.value = input.value + (out.dataset.unit || \"\");\n  }\n</script>`;\n\nconst pascal = (s: string) => s.replace(/(^|[^a-zA-Z0-9]+)([a-zA-Z0-9])/g, (_, __, c: string) => c.toUpperCase());\nconst cssCode = (it: Item) => `<!-- ${it.name}: plain HTML + CSS, no framework -->\\n${cssFor(it.theme)}\\n\\n${serial(it.node, \"css\", 0)}\\n\\n${SCRIPT}\\n`;\nconst twCode = (it: Item) => `<!-- ${it.name}: needs Tailwind CSS v3.2+ or v4 on the page -->\\n${serial(it.node, \"tw\", 0)}\\n\\n${SCRIPT}\\n`;\n\n/* ---------- live behaviour inside the preview (same logic as SCRIPT) ---------- */\nfunction syncOutputs(form: HTMLFormElement) {\n  form.querySelectorAll(\"output\").forEach((out) => {\n    const input = form.querySelector<HTMLInputElement>(`#${out.htmlFor.value}`);\n    if (input) out.value = input.value + (out.dataset.unit ?? \"\");\n  });\n}\n\nfunction validate(form: HTMLFormElement) {\n  const status = form.querySelector<HTMLElement>(\"[role=status]\");\n  let firstBad: HTMLElement | null = null;\n  for (const node of Array.from(form.elements)) {\n    const el = node as HTMLInputElement;\n    if (!el.willValidate) continue;\n    const key = el.type === \"radio\" ? el.name : el.id;\n    const err = form.querySelector<HTMLElement>(`#${key}-err`);\n    const bad = !el.checkValidity();\n    if (bad) el.setAttribute(\"aria-invalid\", \"true\");\n    else el.removeAttribute(\"aria-invalid\");\n    if (err) {\n      err.hidden = !bad;\n      const ids = (el.getAttribute(\"aria-describedby\") ?? \"\").split(\" \").filter((id) => id && id !== err.id);\n      if (bad) ids.push(err.id);\n      if (ids.length) el.setAttribute(\"aria-describedby\", ids.join(\" \"));\n      else el.removeAttribute(\"aria-describedby\");\n    }\n    if (bad && !firstBad) firstBad = el;\n  }\n  if (!status) return;\n  if (firstBad) {\n    status.dataset.state = \"error\";\n    status.textContent = \"Please fix the highlighted fields.\";\n    firstBad.focus();\n  } else {\n    status.dataset.state = \"ok\";\n    status.textContent = \"Thanks, that all checks out. This demo sends nothing.\";\n  }\n}\n\nfunction LiveForm({ node }: { node: El }) {\n  const tree = useMemo(() => toReact(node, 0), [node]);\n  const onSubmit = (e: SyntheticEvent) => {\n    e.preventDefault();\n    validate(e.target as HTMLFormElement);\n  };\n  const onReset = (e: SyntheticEvent) => {\n    const form = e.target as HTMLFormElement;\n    form.querySelectorAll(\"[aria-invalid]\").forEach((el) => el.removeAttribute(\"aria-invalid\"));\n    form.querySelectorAll<HTMLElement>(\".f-error, [id$='-err']\").forEach((el) => { el.hidden = true; });\n    const status = form.querySelector<HTMLElement>(\"[role=status]\");\n    if (status) status.textContent = \"\";\n    setTimeout(() => syncOutputs(form), 0);\n  };\n  const onInput = (e: SyntheticEvent) => {\n    const el = e.target as HTMLInputElement;\n    if (el.type === \"range\" && el.form) syncOutputs(el.form);\n  };\n  const onClick = (e: SyntheticEvent) => {\n    const b = e.target as HTMLButtonElement;\n    if (!b.hasAttribute?.(\"data-reveal\") || !b.form) return;\n    const pw = b.form.querySelector<HTMLInputElement>(\"input[autocomplete=current-password]\");\n    if (!pw) return;\n    const show = pw.type === \"password\";\n    pw.type = show ? \"text\" : \"password\";\n    b.setAttribute(\"aria-pressed\", String(show));\n    b.textContent = show ? \"Hide password\" : \"Show password\";\n  };\n  return <div onSubmitCapture={onSubmit} onResetCapture={onReset} onInputCapture={onInput} onClickCapture={onClick}>{tree}</div>;\n}\n\n/* ---------- reference data ---------- */\nconst REF: [string, string, string, string][] = [\n  [\"text\", \"Names, subjects, codes\", \"minlength, maxlength, pattern\", \"Plain box. Add inputmode=\\\"numeric\\\" for digit codes.\"],\n  [\"email\", \"One or more email addresses\", \"multiple, pattern\", \"Checks for a name@domain shape; phones show an @ key.\"],\n  [\"password\", \"Secrets\", \"minlength, autocomplete\", \"Characters are masked; use new-password or current-password so managers fill it.\"],\n  [\"tel\", \"Phone numbers\", \"pattern, autocomplete=\\\"tel\\\"\", \"No format check of its own; phones open a dial pad.\"],\n  [\"url\", \"Web addresses\", \"pattern, placeholder\", \"Only valid with a scheme, such as https at the start.\"],\n  [\"number\", \"Quantities and counts\", \"min, max, step\", \"Spin buttons. Not for card numbers, postcodes or phone numbers.\"],\n  [\"search\", \"Search boxes\", \"name=\\\"q\\\", placeholder\", \"Behaves like text; some browsers add a clear button.\"],\n  [\"date\", \"A calendar day\", \"min, max\", \"Picker varies by browser; value is always YYYY-MM-DD.\"],\n  [\"time\", \"A time of day\", \"min, max, step (seconds)\", \"step=\\\"900\\\" gives 15 minute slots; value is HH:MM.\"],\n  [\"datetime-local\", \"Date and time, no time zone\", \"min, max, step\", \"Value looks like 2026-11-15T19:00.\"],\n  [\"month\", \"A year and month\", \"min, max\", \"Value YYYY-MM. Firefox and desktop Safari show a plain text box.\"],\n  [\"week\", \"A numbered week\", \"min, max\", \"Value like 2026-W43. Same support gaps as month.\"],\n  [\"color\", \"A colour\", \"value (hex)\", \"Opens the system colour picker; value is #rrggbb, default #000000.\"],\n  [\"range\", \"An approximate value\", \"min, max, step, value\", \"Slider that is always valid; pair it with output to show the number.\"],\n  [\"file\", \"Uploads\", \"accept, multiple\", \"Form needs method=\\\"post\\\" and enctype=\\\"multipart/form-data\\\".\"],\n  [\"checkbox\", \"Yes or no, or many of a list\", \"name, value, checked, required\", \"Unticked boxes send nothing; a ticked box with no value sends \\\"on\\\".\"],\n  [\"radio\", \"One choice from a few\", \"same name, value, required\", \"required on the group means one must be picked.\"],\n  [\"hidden\", \"Data the user does not edit\", \"name, value\", \"Invisible but visible in the page source; never trust it on the server.\"],\n  [\"submit\", \"Sends the form\", \"formaction, formnovalidate\", \"A button element with type=\\\"submit\\\" does the same and can hold icons.\"],\n  [\"reset\", \"Restores defaults\", \"value\", \"Easy to press by accident; keep it secondary.\"],\n  [\"button\", \"Runs your script\", \"value\", \"Does nothing on its own; used here for Show password.\"],\n  [\"textarea\", \"Longer text\", \"rows, minlength, maxlength\", \"Its own element, not an input type.\"],\n  [\"select\", \"One option from a list\", \"required, multiple\", \"A first option with value=\\\"\\\" makes required work.\"],\n  [\"datalist\", \"Suggestions for a text input\", \"id, matched by list\", \"Suggests but does not restrict what can be typed.\"],\n  [\"output\", \"A calculated result\", \"for, name\", \"Announced politely to screen readers when it changes.\"],\n  [\"fieldset + legend\", \"Groups related controls\", \"disabled\", \"The legend is read before each radio or checkbox inside.\"],\n];\n\n/* ---------- page ---------- */\nconst FAMILY_KEYS = Object.keys(FAMILIES) as Family[];\ntype Lang = \"css\" | \"tw\";\n\nexport default function HtmlFormExamplesCollection() {\n  const [family, setFamily] = useState<Family | \"all\">(\"all\");\n  const [query, setQuery] = useState(\"\");\n  const [open, setOpen] = useState<number | null>(null);\n  const [lang, setLang] = useState<Lang>(\"css\");\n  const [copied, setCopied] = useState<string | null>(null);\n  const [announce, setAnnounce] = useState(\"\");\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  useEffect(() => () => { if (timer.current) clearTimeout(timer.current); }, []);\n\n  const q = query.trim().toLowerCase();\n  const visible = ITEMS.map((it, i) => ({ it, i })).filter(({ it }) => (family === \"all\" || it.f === family) && (!q || `${it.name} ${FAMILIES[it.f]} ${it.types.join(\" \")}`.toLowerCase().includes(q)));\n\n  async function copy(i: number, l: Lang) {\n    const it = ITEMS[i];\n    let ok = false;\n    try {\n      await navigator.clipboard.writeText(l === \"css\" ? cssCode(it) : twCode(it));\n      ok = true;\n    } catch {\n      ok = false;\n    }\n    if (!ok) { setOpen(i); setLang(l); }\n    setCopied(ok ? `${i}-${l}` : null);\n    setAnnounce(ok ? `${it.name} ${l === \"css\" ? \"HTML and CSS\" : \"Tailwind HTML\"} copied` : \"Copy was blocked, the code is shown below so you can select it\");\n    if (timer.current) clearTimeout(timer.current);\n    timer.current = setTimeout(() => setCopied(null), 1600);\n  }\n\n  const ring = \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-1\";\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  const tool = `inline-flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg px-3 text-[12.5px] font-semibold transition-colors ${ring}`;\n  const LABEL: Record<Lang, string> = { css: \"HTML + CSS\", tw: \"Tailwind\" };\n\n  return (\n    <section className=\"bg-[#f5f5f2] px-4 py-12 text-[#16181d] 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-7xl\">\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-stone-600\">HTML · CSS · Tailwind</p>\n            <h2 className=\"mt-3 text-[32px] font-semibold leading-[1.05] tracking-[-0.03em] sm:text-[44px]\">{ITEMS.length} HTML form examples, every input type</h2>\n            <p className=\"mt-4 max-w-xl text-[15px] leading-relaxed text-stone-600\">\n              Each form is live: fill it in and press the button to see the browser's own validation at work. Copy it as plain HTML with a small CSS block, or as Tailwind HTML.\n            </p>\n          </div>\n          <dl className=\"flex gap-8 font-mono text-[12px] text-stone-600\">\n            <div><dt className=\"uppercase tracking-[0.14em]\">Forms</dt><dd className=\"mt-1 text-[22px] font-semibold tracking-tight text-[#16181d]\">{ITEMS.length}</dd></div>\n            <div><dt className=\"uppercase tracking-[0.14em]\">Input types</dt><dd className=\"mt-1 text-[22px] font-semibold tracking-tight text-[#16181d]\">21</dd></div>\n          </dl>\n        </header>\n\n        <div className=\"mt-8 flex flex-col gap-3 border-y border-stone-300/70 py-4 lg:flex-row lg:items-center\">\n          <label htmlFor=\"hfe-search\" className=\"sr-only\">Search forms or input types</label>\n          <div className=\"relative lg:w-64 lg:shrink-0\">\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" aria-hidden=\"true\" className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-stone-500\">\n              <path d=\"M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4\" />\n            </svg>\n            <input id=\"hfe-search\" type=\"search\" value={query} onChange={(e) => setQuery(e.target.value)} placeholder=\"Try date, file or login\"\n              className=\"h-10 w-full rounded-full border border-stone-300 bg-white pl-9 pr-4 text-[14px] text-stone-900 placeholder:text-stone-500 focus:border-stone-500 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-700\" />\n          </div>\n          <div className=\"flex flex-wrap gap-1.5\" role=\"group\" aria-label=\"Filter by kind of form\">\n            {([\"all\", ...FAMILY_KEYS] as const).map((f) => {\n              const on = family === f;\n              const n = f === \"all\" ? ITEMS.length : ITEMS.filter((it) => it.f === f).length;\n              return (\n                <button key={f} type=\"button\" aria-pressed={on} onClick={() => setFamily(f)} className={`${chip} ${on ? \"bg-[#16181d] text-white\" : \"bg-white text-stone-700 ring-1 ring-inset ring-stone-300 hover:bg-stone-100\"}`}>\n                  {f === \"all\" ? \"All\" : FAMILIES[f]}\n                  <span className={`font-mono text-[11px] ${on ? \"text-stone-300\" : \"text-stone-500\"}`}>{n}</span>\n                </button>\n              );\n            })}\n          </div>\n        </div>\n\n        <p className=\"sr-only\" aria-live=\"polite\">{announce}</p>\n\n        <div className=\"relative mt-6 h-[1180px] overflow-y-auto overscroll-contain rounded-2xl pr-1\" tabIndex={0} aria-label=\"Form examples and input type reference\">\n          {visible.length === 0 && (\n            <div className=\"grid h-48 place-items-center rounded-2xl border border-dashed border-stone-300 px-4 text-center text-[14px] text-stone-600\">No form matches \"{query}\". Try email, range or checkout.</div>\n          )}\n          <ul className=\"grid grid-cols-1 items-start gap-4 lg:grid-cols-2\">\n            {visible.map(({ it, i }) => {\n              const isOpen = open === i;\n              return (\n                <li key={i} className={`overflow-hidden rounded-2xl border border-stone-200 bg-white shadow-[0_1px_2px_rgba(22,24,29,0.04)] ${isOpen ? \"lg:col-span-2\" : \"\"}`}>\n                  <LiveForm node={it.node} />\n                  <div className=\"border-t border-stone-200 px-3 py-2.5\">\n                    <div className=\"flex flex-wrap items-center gap-2\">\n                      <span className=\"font-mono text-[11px] text-stone-500\">{String(i + 1).padStart(2, \"0\")}</span>\n                      <span className=\"min-w-0 flex-1 basis-36 truncate text-[13px] font-medium text-stone-800\">{it.name}</span>\n                      <button type=\"button\" aria-expanded={isOpen} aria-controls={`hfe-code-${i}`} onClick={() => setOpen(isOpen ? null : i)} className={`${tool} text-stone-700 hover:bg-stone-100`}>\n                        <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-4 w-4\"><path d=\"M8 7l-5 5 5 5M16 7l5 5-5 5\" /></svg>\n                        Code\n                      </button>\n                      {([\"css\", \"tw\"] as const).map((l) => {\n                        const done = copied === `${i}-${l}`;\n                        return (\n                          <button key={l} type=\"button\" onClick={() => copy(i, l)} aria-label={`Copy ${LABEL[l]} for ${it.name}`} className={`${tool} ${done ? \"bg-emerald-700 text-white\" : \"bg-stone-100 text-stone-900 hover:bg-stone-200\"}`}>\n                            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"h-3.5 w-3.5\"><path d={done ? \"M5 12.5l4.5 4.5L19 7\" : \"M9 9h11v11H9zM5 15H4V4h11v1\"} /></svg>\n                            {done ? \"Copied\" : LABEL[l]}\n                          </button>\n                        );\n                      })}\n                    </div>\n                    <p className=\"mt-1.5 font-mono text-[11px] leading-5 text-stone-600\">{it.types.join(\" · \")}</p>\n                  </div>\n                  {isOpen && (\n                    <div id={`hfe-code-${i}`} className=\"border-t border-stone-800 bg-[#111318]\">\n                      <div className=\"flex gap-1 border-b border-white/10 px-3 pt-2\" role=\"group\" aria-label=\"Code format\">\n                        {([\"css\", \"tw\"] as const).map((l) => (\n                          <button key={l} type=\"button\" aria-pressed={lang === l} onClick={() => setLang(l)} className={`rounded-t-md px-3 py-2 text-[12px] font-semibold ${ring} ${lang === l ? \"bg-white/10 text-white\" : \"text-slate-400 hover:text-white\"}`}>\n                            {LABEL[l]}\n                          </button>\n                        ))}\n                      </div>\n                      <pre tabIndex={0} className=\"max-h-96 overflow-auto p-4 font-mono text-[11.5px] leading-[1.65] text-slate-200\">\n                        <code>{lang === \"css\" ? cssCode(it) : twCode(it)}</code>\n                      </pre>\n                    </div>\n                  )}\n                </li>\n              );\n            })}\n          </ul>\n\n          <div className=\"mt-10 grid gap-6 lg:grid-cols-[1fr_320px]\">\n            <div className=\"rounded-2xl border border-stone-200 bg-white p-5 sm:p-6\">\n              <h3 className=\"text-lg font-semibold tracking-tight\">Input type reference</h3>\n              <p className=\"mt-1 text-[14px] text-stone-600\">Every type used above, what it is for and what the browser adds.</p>\n              <div className=\"mt-4 overflow-x-auto\">\n                <table className=\"w-full min-w-[640px] border-collapse text-left text-[13px]\">\n                  <caption className=\"sr-only\">HTML input types and related form elements</caption>\n                  <thead>\n                    <tr className=\"border-b border-stone-300 text-stone-600\">\n                      <th scope=\"col\" className=\"py-2 pr-4 font-semibold\">Type</th>\n                      <th scope=\"col\" className=\"py-2 pr-4 font-semibold\">For</th>\n                      <th scope=\"col\" className=\"py-2 pr-4 font-semibold\">Key attributes</th>\n                      <th scope=\"col\" className=\"py-2 font-semibold\">Browser note</th>\n                    </tr>\n                  </thead>\n                  <tbody>\n                    {REF.map(([ty, use, attr, note]) => (\n                      <tr key={ty} className=\"border-b border-stone-100 align-top\">\n                        <th scope=\"row\" className=\"whitespace-nowrap py-2 pr-4 font-mono font-semibold text-stone-900\">{ty}</th>\n                        <td className=\"py-2 pr-4 text-stone-700\">{use}</td>\n                        <td className=\"py-2 pr-4 font-mono text-[12px] text-stone-700\">{attr}</td>\n                        <td className=\"py-2 text-stone-700\">{note}</td>\n                      </tr>\n                    ))}\n                  </tbody>\n                </table>\n              </div>\n            </div>\n            <aside className=\"h-fit rounded-2xl bg-[#16181d] p-6 text-stone-200\">\n              <h3 className=\"text-lg font-semibold tracking-tight text-white\">Send it without a backend</h3>\n              <p className=\"mt-3 text-[14px] leading-6\">\n                Every form here uses <code className=\"rounded bg-white/10 px-1 font-mono text-[12.5px] text-white\">action=\"#\"</code> and <code className=\"rounded bg-white/10 px-1 font-mono text-[12.5px] text-white\">method=\"post\"</code>. To receive real submissions, set <code className=\"rounded bg-white/10 px-1 font-mono text-[12.5px] text-white\">action</code> to the address a form-handling service gives you.\n              </p>\n              <p className=\"mt-3 text-[14px] leading-6\">\n                Keep a <code className=\"rounded bg-white/10 px-1 font-mono text-[12.5px] text-white\">name</code> on every field, since only named fields are sent. Forms with a file input also need <code className=\"rounded bg-white/10 px-1 font-mono text-[12.5px] text-white\">enctype=\"multipart/form-data\"</code>.\n              </p>\n              <p className=\"mt-3 text-[14px] leading-6\">\n                The script only calls submit once every field passes, so the browser's checks still run first. Always validate again on the receiving side.\n              </p>\n            </aside>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
