{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "comp-24",
  "type": "registry:component",
  "registryDependencies": [
    "https://coss.com/origin/r/input.json",
    "https://coss.com/origin/r/label.json"
  ],
  "files": [
    {
      "path": "registry/default/components/comp-24.tsx",
      "content": "\"use client\";\n\nimport { CircleXIcon } from \"lucide-react\";\nimport { useId, useRef, useState } from \"react\";\n\nimport { Input } from \"@/registry/default/ui/input\";\nimport { Label } from \"@/registry/default/ui/label\";\n\nexport default function Component() {\n  const id = useId();\n  const [inputValue, setInputValue] = useState(\"Click to clear\");\n  const inputRef = useRef<HTMLInputElement>(null);\n\n  const handleClearInput = () => {\n    setInputValue(\"\");\n    if (inputRef.current) {\n      inputRef.current.focus();\n    }\n  };\n\n  return (\n    <div className=\"*:not-first:mt-2\">\n      <Label htmlFor={id}>Input with clear button</Label>\n      <div className=\"relative\">\n        <Input\n          className=\"pe-9\"\n          id={id}\n          onChange={(e) => setInputValue(e.target.value)}\n          placeholder=\"Type something...\"\n          ref={inputRef}\n          type=\"text\"\n          value={inputValue}\n        />\n        {inputValue && (\n          <button\n            aria-label=\"Clear input\"\n            className=\"absolute inset-y-0 end-0 flex h-full w-9 items-center justify-center rounded-e-md text-muted-foreground/80 outline-none transition-[color,box-shadow] hover:text-foreground focus:z-10 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50\"\n            onClick={handleClearInput}\n            type=\"button\"\n          >\n            <CircleXIcon aria-hidden=\"true\" size={16} />\n          </button>\n        )}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "tags": [
      "input",
      "label",
      "button"
    ]
  }
}