{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "input-group",
  "title": "Input Group",
  "description": "Joins an input with text addons, icons, a select or a button into one field with one border and one focus ring: https:// and .com around a subdomain with a live availability tick, a price with a currency picker, a search with a shortcut, an invite with a send button.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/input-group/input-group.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type InputGroupSize = \"sm\" | \"md\" | \"lg\";\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.5)\", bg: \"rgba(255,255,255,0.03)\", addon: \"rgba(255,255,255,0.05)\", border: \"rgba(255,255,255,0.12)\", borderHover: \"rgba(255,255,255,0.24)\", divider: \"rgba(255,255,255,0.1)\", focus: \"rgba(245,244,241,0.85)\", solid: \"#F5F4F1\", solidText: \"#0A0A0A\", ok: \"#3FBF7F\", error: \"#FF7A6B\", kbd: \"rgba(255,255,255,0.08)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.5)\", bg: \"#FFFFFF\", addon: \"rgba(10,10,10,0.04)\", border: \"rgba(10,10,10,0.16)\", borderHover: \"rgba(10,10,10,0.3)\", divider: \"rgba(10,10,10,0.1)\", focus: \"rgba(10,10,10,0.85)\", solid: \"#0A0A0A\", solidText: \"#FFFFFF\", ok: \"#1F9D5C\", error: \"#E5484D\", kbd: \"rgba(10,10,10,0.06)\" },\n};\n\nconst SIZES: Record<InputGroupSize, { h: number; font: number; radius: number; pad: number }> = {\n  sm: { h: 36, font: 13, radius: 10, pad: 11 },\n  md: { h: 44, font: 14.5, radius: 12, pad: 13 },\n  lg: { h: 52, font: 16, radius: 14, pad: 15 },\n};\n\ntype Ctx = { p: (typeof PALETTES)[\"dark\"]; s: (typeof SIZES)[\"md\"]; reduce: boolean };\nconst GroupCtx = React.createContext<Ctx>({ p: PALETTES.dark, s: SIZES.md, reduce: false });\n\nexport interface InputGroupProps {\n  children?: React.ReactNode;\n  size?: InputGroupSize;\n  /** Error message; turns the frame coral and shows under it. */\n  error?: string;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\n/** A frame that joins inputs, text addons, selects and buttons into one field with one focus ring. */\nexport function InputGroup({ children, size = \"md\", error, theme = \"dark\", className }: InputGroupProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n  const reduce = Boolean(useReducedMotion());\n  const [hover, setHover] = React.useState(false);\n  const [focus, setFocus] = React.useState(false);\n  const errId = React.useId();\n  return (\n    <GroupCtx.Provider value={{ p, s, reduce }}>\n      <div className={cn(\"flex w-full flex-col\", className)} style={{ gap: 6, fontFamily: \"Inter, sans-serif\" }}>\n        <div\n          role=\"group\"\n          aria-describedby={error ? errId : undefined}\n          className=\"flex w-full items-stretch overflow-hidden\"\n          style={{\n            height: s.h,\n            borderRadius: s.radius,\n            background: p.bg,\n            border: `1px solid ${error ? p.error : focus ? p.focus : hover ? p.borderHover : p.border}`,\n            boxShadow: focus ? `0 0 0 3px color-mix(in srgb, ${error ? p.error : p.focus} 14%, transparent)` : \"none\",\n            transition: \"border-color 0.18s ease, box-shadow 0.18s ease\",\n          }}\n          onMouseEnter={() => setHover(true)}\n          onMouseLeave={() => setHover(false)}\n          onFocus={() => setFocus(true)}\n          onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node) && setFocus(false)}\n        >\n          {children}\n        </div>\n        <AnimatePresence initial={false}>\n          {error && (\n            <motion.span key=\"e\" id={errId} role=\"alert\" className=\"text-[12.5px] font-medium\" style={{ color: p.error, paddingLeft: 4 }} initial={{ opacity: 0, y: -3 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0 }}>\n              {error}\n            </motion.span>\n          )}\n        </AnimatePresence>\n      </div>\n    </GroupCtx.Provider>\n  );\n}\n\n/** Static text or an icon attached to the field (e.g. \"https://\", \"$\", \".com\"). */\nexport function InputGroupAddon({ children, plain = false }: { children: React.ReactNode; plain?: boolean }) {\n  const { p, s } = React.useContext(GroupCtx);\n  return (\n    <span className=\"flex shrink-0 items-center whitespace-nowrap select-none\" style={{ padding: `0 ${plain ? 0 : s.pad}px`, paddingLeft: plain ? s.pad : undefined, fontSize: s.font, color: p.muted, background: plain ? \"transparent\" : p.addon, borderRight: plain ? undefined : `1px solid ${p.divider}`, borderLeft: plain ? undefined : `1px solid ${p.divider}`, marginLeft: -1, marginRight: -1 }}>\n      {children}\n    </span>\n  );\n}\n\nexport function InputGroupInput(props: React.InputHTMLAttributes<HTMLInputElement>) {\n  const { p, s } = React.useContext(GroupCtx);\n  return <input {...props} className={cn(\"h-full min-w-0 flex-1 border-none bg-transparent outline-none placeholder:text-[var(--ig-ph)]\", props.className)} style={{ padding: `0 ${s.pad}px`, fontSize: s.font, color: p.text, [\"--ig-ph\" as string]: p.muted, ...props.style }} />;\n}\n\nexport function InputGroupSelect({ options, value, onChange, label }: { options: string[]; value?: string; onChange?: (v: string) => void; label: string }) {\n  const { p, s } = React.useContext(GroupCtx);\n  return (\n    <label className=\"relative flex shrink-0 items-center\" style={{ borderLeft: `1px solid ${p.divider}`, background: p.addon }}>\n      <span className=\"sr-only\">{label}</span>\n      <select value={value} onChange={(e) => onChange?.(e.target.value)} className=\"h-full cursor-pointer appearance-none border-none bg-transparent font-medium outline-none\" style={{ padding: `0 ${s.pad + 18}px 0 ${s.pad}px`, fontSize: s.font, color: p.text, colorScheme: p.text === \"#F5F4F1\" ? \"dark\" : \"light\" }}>\n        {options.map((o) => (\n          <option key={o}>{o}</option>\n        ))}\n      </select>\n      <svg className=\"pointer-events-none absolute\" style={{ right: s.pad - 2 }} width=\"11\" height=\"11\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.muted} strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n        <path d=\"m6 9 6 6 6-6\" />\n      </svg>\n    </label>\n  );\n}\n\nexport function InputGroupButton({ children, onClick, done, doneLabel = \"Done\" }: { children: React.ReactNode; onClick?: () => void; done?: boolean; doneLabel?: React.ReactNode }) {\n  const { p, s, reduce } = React.useContext(GroupCtx);\n  return (\n    <motion.button\n      type=\"button\"\n      onClick={onClick}\n      className=\"relative flex shrink-0 cursor-pointer items-center justify-center border-none font-semibold whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-inset\"\n      style={{ padding: `0 ${s.pad + 2}px`, fontSize: s.font - 0.5, background: done ? p.ok : p.solid, color: p.solidText, margin: 3, borderRadius: s.radius - 4, transition: \"background 0.2s ease\", [\"--tw-ring-color\" as string]: p.focus }}\n      whileTap={reduce ? undefined : { scale: 0.95 }}\n      layout\n    >\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        <motion.span key={done ? \"done\" : \"idle\"} className=\"flex items-center\" style={{ gap: 6 }} initial={{ opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -8 }} transition={{ duration: reduce ? 0 : 0.18 }}>\n          {done ? doneLabel : children}\n        </motion.span>\n      </AnimatePresence>\n    </motion.button>\n  );\n}\n\n/** A demo set of groups: subdomain with an availability check, price with currency, search, invite. */\nexport function InputGroupDemo({ theme = \"dark\", size = \"md\" }: { theme?: \"dark\" | \"light\"; size?: InputGroupSize }) {\n  const p = PALETTES[theme];\n  const [sub, setSub] = React.useState(\"northwind\");\n  const [check, setCheck] = React.useState<\"idle\" | \"checking\" | \"ok\" | \"taken\">(\"ok\");\n  const [sent, setSent] = React.useState(false);\n  const [email, setEmail] = React.useState(\"\");\n\n  React.useEffect(() => {\n    if (!sub) return;\n    const a = window.setTimeout(() => setCheck(\"checking\"), 0);\n    const b = window.setTimeout(() => setCheck([\"admin\", \"www\", \"app\"].includes(sub) ? \"taken\" : \"ok\"), 650);\n    return () => {\n      window.clearTimeout(a);\n      window.clearTimeout(b);\n    };\n  }, [sub]);\n\n  return (\n    <div className=\"flex w-full flex-col\" style={{ gap: 18 }}>\n      <InputGroup theme={theme} size={size} error={check === \"taken\" ? \"That address is taken. Try another.\" : undefined}>\n        <InputGroupAddon>https://</InputGroupAddon>\n        <InputGroupInput aria-label=\"Subdomain\" value={sub} onChange={(e) => setSub(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, \"\"))} />\n        <InputGroupAddon>\n          <span className=\"flex items-center\" style={{ gap: 8 }}>\n            .reactframe.com\n            <AnimatePresence mode=\"popLayout\" initial={false}>\n              {check === \"checking\" ? (\n                <motion.svg key=\"spin\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" aria-label=\"Checking\" initial={{ opacity: 0 }} animate={{ opacity: 1, rotate: 360 }} exit={{ opacity: 0 }} transition={{ rotate: { duration: 0.8, repeat: Infinity, ease: \"linear\" } }}>\n                  <path d=\"M12 3a9 9 0 1 0 9 9\" />\n                </motion.svg>\n              ) : check === \"ok\" ? (\n                <motion.span key=\"ok\" className=\"flex items-center justify-center rounded-full\" style={{ width: 16, height: 16, background: p.ok }} initial={{ scale: 0 }} animate={{ scale: 1 }} exit={{ scale: 0 }} aria-label=\"Available\" role=\"img\">\n                  <svg width=\"9\" height=\"9\" viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n                    <path d=\"M2.4 6.3 4.9 8.7 9.6 3.4\" stroke=\"#0A0A0A\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                  </svg>\n                </motion.span>\n              ) : null}\n            </AnimatePresence>\n          </span>\n        </InputGroupAddon>\n      </InputGroup>\n\n      <InputGroup theme={theme} size={size}>\n        <InputGroupAddon>$</InputGroupAddon>\n        <InputGroupInput aria-label=\"Price\" inputMode=\"decimal\" defaultValue=\"49.00\" />\n        <InputGroupSelect label=\"Currency\" options={[\"USD\", \"EUR\", \"GBP\", \"TRY\"]} />\n      </InputGroup>\n\n      <InputGroup theme={theme} size={size}>\n        <InputGroupAddon plain>\n          <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n            <circle cx=\"11\" cy=\"11\" r=\"7\" />\n            <path d=\"m20 20-3.5-3.5\" />\n          </svg>\n        </InputGroupAddon>\n        <InputGroupInput aria-label=\"Search docs\" placeholder=\"Search docs…\" />\n        <span className=\"flex shrink-0 items-center\" style={{ paddingRight: 10, gap: 3 }}>\n          {[\"⌘\", \"K\"].map((k) => (\n            <kbd key={k} className=\"rounded-md text-[11.5px] font-semibold\" style={{ padding: \"2px 7px\", background: p.kbd, color: p.muted, fontFamily: \"inherit\" }}>\n              {k}\n            </kbd>\n          ))}\n        </span>\n      </InputGroup>\n\n      <InputGroup theme={theme} size={size}>\n        <InputGroupInput aria-label=\"Teammate's email\" type=\"email\" placeholder=\"teammate@company.com\" value={email} onChange={(e) => setEmail(e.target.value)} />\n        <InputGroupButton\n          done={sent}\n          doneLabel={\n            <>\n              <svg width=\"13\" height=\"13\" viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n                <path d=\"M2.4 6.3 4.9 8.7 9.6 3.4\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n              </svg>\n              Sent\n            </>\n          }\n          onClick={() => {\n            setSent(true);\n            window.setTimeout(() => {\n              setSent(false);\n              setEmail(\"\");\n            }, 1600);\n          }}\n        >\n          Send invite\n        </InputGroupButton>\n      </InputGroup>\n    </div>\n  );\n}\n\nexport default InputGroup;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}