{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"droop-field","type":"registry:ui","title":"Droop Field","description":"A text field whose words and underline droop along an arc while idle, then spring flat the moment you focus it.","dependencies":["motion"],"registryDependencies":[],"files":[{"path":"registry/ui/droop-field.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useId, useState, type InputHTMLAttributes } from \"react\";\nimport { motion, useReducedMotion, useSpring, useTransform } from \"motion/react\";\n\nexport interface DroopFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"size\" | \"value\" | \"defaultValue\" | \"onChange\"> {\n  /** Width in px. */\n  width?: number;\n  /** Text size in px. */\n  fontSize?: number;\n  /** Px the middle of the arc sags while idle. Negative arcs upwards. */\n  bend?: number;\n  placeholder?: string;\n  defaultValue?: string;\n  /** Accessible label. */\n  label?: string;\n  /** Underline gradient start. */\n  colorFrom?: string;\n  /** Underline gradient end. */\n  colorTo?: string;\n  onValueChange?: (value: string) => void;\n  className?: string;\n}\n\nexport function DroopField({\n  width = 380,\n  fontSize = 30,\n  bend = 40,\n  placeholder = \"Type your name\",\n  defaultValue = \"\",\n  label = \"Name\",\n  colorFrom = \"#a78bfa\",\n  colorTo = \"#22d3ee\",\n  onValueChange,\n  className,\n  ...rest\n}: DroopFieldProps) {\n  const id = useId();\n  const reduce = useReducedMotion();\n  const [value, setValue] = useState(defaultValue);\n  const [focused, setFocused] = useState(false);\n  const b = useSpring(bend, reduce ? { duration: 0 } : { stiffness: 220, damping: 14, mass: 0.9 });\n\n  useEffect(() => {\n    b.set(focused ? 0 : bend);\n  }, [b, bend, focused]);\n\n  const pad = Math.abs(bend) + 8;\n  const base = pad + fontSize * 1.05; // text baseline when flat\n  const line = base + fontSize * 0.45; // underline\n  const height = line + pad + 8;\n  const curve = (y: number) => (v: number) => `M 4 ${y} Q ${width / 2} ${y + 2 * v} ${width - 4} ${y}`;\n  const textD = useTransform(b, curve(base));\n  const lineD = useTransform(b, curve(line));\n  const showText = value || placeholder;\n  const swap = reduce ? \"0s\" : focused ? \".18s .22s\" : \"0s\";\n\n  return (\n    <label className={`relative block cursor-text ${className ?? \"\"}`} style={{ width, height }}>\n      <svg aria-hidden width={width} height={height} className=\"pointer-events-none absolute inset-0 overflow-visible\">\n        <defs>\n          <motion.path id={`${id}-t`} d={textD} />\n          <linearGradient id={`${id}-g`} x1=\"0\" x2=\"1\">\n            <stop offset=\"0\" stopColor={colorFrom} />\n            <stop offset=\"1\" stopColor={colorTo} />\n          </linearGradient>\n        </defs>\n        <text\n          className={value ? \"fill-foreground\" : \"fill-muted-foreground\"}\n          style={{ fontSize, fontWeight: 600, letterSpacing: \"-0.01em\", opacity: focused ? 0 : 1, transition: `opacity ${swap}` }}\n        >\n          <textPath href={`#${id}-t`} startOffset=\"50%\" textAnchor=\"middle\">\n            {showText}\n          </textPath>\n        </text>\n        <motion.path d={lineD} fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" className=\"text-border\" />\n        <motion.path\n          d={lineD}\n          fill=\"none\"\n          stroke={`url(#${id}-g)`}\n          strokeWidth={3}\n          strokeLinecap=\"round\"\n          initial={false}\n          animate={{ pathLength: focused ? 1 : value ? 0.35 : 0, opacity: focused || value ? 1 : 0 }}\n          transition={{ duration: reduce ? 0 : 0.6, ease: [0.22, 1, 0.36, 1] }}\n        />\n      </svg>\n      <input\n        {...rest}\n        aria-label={label}\n        value={value}\n        placeholder={placeholder}\n        onChange={(e) => {\n          setValue(e.target.value);\n          onValueChange?.(e.target.value);\n        }}\n        onFocus={(e) => {\n          setFocused(true);\n          rest.onFocus?.(e);\n        }}\n        onBlur={(e) => {\n          setFocused(false);\n          rest.onBlur?.(e);\n        }}\n        className={`absolute inset-x-0 w-full bg-transparent text-center font-semibold tracking-[-0.01em] text-foreground caret-foreground outline-none ${focused ? \"placeholder:text-muted-foreground\" : \"placeholder:text-transparent\"}`}\n        style={{\n          top: base - fontSize * 1.05,\n          height: fontSize * 1.4,\n          fontSize,\n          color: focused ? undefined : \"transparent\",\n          transition: `color ${swap}`,\n        }}\n      />\n    </label>\n  );\n}\n"}]}