{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "textarea",
  "title": "Textarea",
  "description": "An accessible textarea with outline, filled, and underline variants, label/helper/error text, optional auto-resize and a character counter, and a focus ring, every color, size, and timing exposed as a prop.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/textarea/textarea.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion } 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 TextareaVariant = \"outline\" | \"filled\" | \"underline\";\nexport type TextareaResize = \"none\" | \"vertical\" | \"both\";\n\nexport interface TextareaProps {\n  value?: string;\n  defaultValue?: string;\n  onChange?: (value: string) => void;\n  placeholder?: string;\n  disabled?: boolean;\n  required?: boolean;\n  optionalText?: boolean;\n  infoText?: string;\n  label?: string;\n  helperText?: string;\n  errorText?: string;\n  variant?: TextareaVariant;\n  rows?: number;\n  autoResize?: boolean;\n  maxLength?: number;\n  showCounter?: boolean;\n  resize?: TextareaResize;\n  fontFamily?: string;\n  paddingX?: number;\n  paddingY?: number;\n  fontSize?: number;\n  radius?: number;\n  borderWidth?: number;\n  borderColor?: string;\n  backgroundColor?: string;\n  textColor?: string;\n  placeholderColor?: string;\n  labelColor?: string;\n  helperColor?: string;\n  mutedColor?: string;\n  requiredColor?: string;\n  errorColor?: string;\n  accentColor?: string;\n  ringColor?: string;\n  ringWidth?: number;\n  duration?: number;\n  fullWidth?: boolean;\n  className?: string;\n  id?: string;\n  name?: string;\n}\n\nexport function InfoIcon({ color, size = 14 }: { color: string; size?: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n      <circle cx=\"8\" cy=\"8\" r=\"6.75\" stroke={color} strokeWidth=\"1.4\" />\n      <line x1=\"8\" y1=\"7.2\" x2=\"8\" y2=\"11.2\" stroke={color} strokeWidth=\"1.4\" strokeLinecap=\"round\" />\n      <circle cx=\"8\" cy=\"4.7\" r=\"0.9\" fill={color} />\n    </svg>\n  );\n}\n\nexport function Textarea({\n  value,\n  defaultValue = \"\",\n  onChange,\n  placeholder,\n  disabled = false,\n  required = false,\n  optionalText = false,\n  infoText,\n  label,\n  helperText,\n  errorText,\n  variant = \"outline\",\n  rows = 4,\n  autoResize = false,\n  maxLength,\n  showCounter = false,\n  resize = \"vertical\",\n  fontFamily = \"Inter, system-ui, sans-serif\",\n  paddingX = 14,\n  paddingY = 10,\n  fontSize = 14,\n  radius,\n  borderWidth = 1.5,\n  borderColor = \"#d1d5db\",\n  backgroundColor,\n  textColor = \"currentColor\",\n  placeholderColor = \"color-mix(in srgb, currentColor 40%, transparent)\",\n  labelColor = \"currentColor\",\n  helperColor = \"color-mix(in srgb, currentColor 60%, transparent)\",\n  mutedColor = \"color-mix(in srgb, currentColor 45%, transparent)\",\n  requiredColor = \"#ef4444\",\n  errorColor = \"#ef4444\",\n  accentColor = \"#f59e0b\",\n  ringColor = \"rgba(245,158,11,0.25)\",\n  ringWidth = 3,\n  duration = 0.18,\n  fullWidth = true,\n  className,\n  id,\n  name,\n}: TextareaProps) {\n  const [internalValue, setInternalValue] = React.useState(defaultValue);\n  const [focused, setFocused] = React.useState(false);\n  const textareaRef = React.useRef<HTMLTextAreaElement>(null);\n  const generatedId = React.useId();\n  const textareaId = id ?? `textarea-${generatedId}`;\n  const isControlled = value !== undefined;\n  const currentValue = isControlled ? value : internalValue;\n  const hasError = Boolean(errorText);\n\n  const resolvedRadius = radius ?? (variant === \"underline\" ? 0 : 10);\n  const labelSize = fontSize * 0.95;\n  const helperSize = fontSize * 0.85;\n\n  const activeBorderColor = hasError ? errorColor : focused ? accentColor : borderColor;\n  const activeRingColor = hasError ? \"rgba(239,68,68,0.25)\" : ringColor;\n\n  const variantStyle: React.CSSProperties =\n    variant === \"filled\"\n      ? { backgroundColor: backgroundColor ?? \"color-mix(in srgb, currentColor 6%, transparent)\", border: \"none\", borderBottom: `${borderWidth}px solid ${activeBorderColor}`, borderRadius: `${resolvedRadius}px ${resolvedRadius}px 0 0` }\n      : variant === \"underline\"\n        ? { backgroundColor: backgroundColor ?? \"transparent\", border: \"none\", borderBottom: `${borderWidth}px solid ${activeBorderColor}`, borderRadius: 0 }\n        : { backgroundColor: backgroundColor ?? \"transparent\", border: `${borderWidth}px solid ${activeBorderColor}`, borderRadius: resolvedRadius };\n\n  const autoSize = React.useCallback(() => {\n    const el = textareaRef.current;\n    if (!el || !autoResize) return;\n    el.style.height = \"auto\";\n    el.style.height = `${el.scrollHeight}px`;\n  }, [autoResize]);\n\n  React.useEffect(() => {\n    autoSize();\n  }, [autoSize, currentValue]);\n\n  const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n    if (!isControlled) setInternalValue(e.target.value);\n    onChange?.(e.target.value);\n  };\n\n  const resolvedResize = autoResize ? \"none\" : resize;\n  const counterText = maxLength ? `${currentValue.length} / ${maxLength}` : `${currentValue.length}`;\n\n  return (\n    <div className={cn(\"flex flex-col gap-1.5\", fullWidth ? \"w-full\" : \"w-fit\", className)} style={{ fontFamily }}>\n      {label && (\n        <label htmlFor={textareaId} className=\"flex items-center gap-1.5\">\n          <span className=\"font-semibold tracking-[-0.01em]\" style={{ color: labelColor, fontSize: labelSize }}>\n            {label}\n          </span>\n          {optionalText && (\n            <span className=\"font-normal\" style={{ color: mutedColor, fontSize: labelSize }}>\n              (optional)\n            </span>\n          )}\n          {required && (\n            <span className=\"font-semibold\" style={{ color: requiredColor, fontSize: labelSize }}>\n              *\n            </span>\n          )}\n          {infoText && (\n            <span title={infoText} className=\"flex\">\n              <InfoIcon color={mutedColor} size={labelSize} />\n            </span>\n          )}\n        </label>\n      )}\n\n      <motion.div\n        className={cn(\"box-border\", fullWidth ? \"w-full\" : \"w-fit\")}\n        style={{ opacity: disabled ? 0.5 : 1, ...variantStyle }}\n        initial={false}\n        animate={{ boxShadow: focused ? `0 0 0 ${ringWidth}px ${activeRingColor}` : \"0 0 0 0px rgba(0,0,0,0)\" }}\n        transition={{ duration }}\n      >\n        <textarea\n          ref={textareaRef}\n          id={textareaId}\n          name={name}\n          value={currentValue}\n          onChange={handleChange}\n          onFocus={() => setFocused(true)}\n          onBlur={() => setFocused(false)}\n          placeholder={placeholder}\n          disabled={disabled}\n          required={required}\n          rows={rows}\n          maxLength={maxLength}\n          aria-invalid={hasError || undefined}\n          aria-describedby={errorText || helperText || showCounter ? `${textareaId}-desc` : undefined}\n          className=\"block w-full border-none bg-transparent outline-none placeholder-[color:var(--textarea-placeholder)]\"\n          style={{\n            color: textColor,\n            fontSize,\n            fontFamily,\n            paddingLeft: paddingX,\n            paddingRight: paddingX,\n            paddingTop: paddingY,\n            paddingBottom: paddingY,\n            resize: resolvedResize,\n            cursor: disabled ? \"default\" : \"text\",\n            [\"--textarea-placeholder\" as string]: placeholderColor,\n          }}\n        />\n      </motion.div>\n\n      {(errorText || helperText || showCounter) && (\n        <div id={`${textareaId}-desc`} className=\"flex items-start justify-between gap-2\">\n          <span className=\"leading-[1.4]\" style={{ color: hasError ? errorColor : helperColor, fontSize: helperSize }}>\n            {errorText || helperText}\n          </span>\n          {showCounter && (\n            <span className=\"shrink-0 leading-[1.4] tabular-nums\" style={{ color: mutedColor, fontSize: helperSize }}>\n              {counterText}\n            </span>\n          )}\n        </div>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}