{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shadcn-studio/input-36","type":"registry:component","title":"Input 36","description":"Input field with clear button to instantly reset the field value","dependencies":["lucide-react"],"registryDependencies":["button","input-group","label"],"files":[{"path":"src/registry/new-york/components/input/input-36.tsx","content":"'use client'\n\nimport { useId, useRef, useState } from 'react'\n\nimport { CircleXIcon } from 'lucide-react'\n\nimport { Button } from '@/registry/new-york/ui/button'\nimport { InputGroup, InputGroupAddon, InputGroupInput } from '@/registry/new-york/ui/input-group'\nimport { Label } from '@/registry/new-york/ui/label'\n\nconst InputClearDemo = () => {\n  const [value, setValue] = useState('Click to clear')\n\n  const inputRef = useRef<HTMLInputElement>(null)\n\n  const id = useId()\n\n  const handleClearInput = () => {\n    setValue('')\n\n    if (inputRef.current) {\n      inputRef.current.focus()\n    }\n  }\n\n  return (\n    <div className='w-full max-w-xs space-y-2'>\n      <Label htmlFor={id}>Input with clear button</Label>\n      <InputGroup>\n        <InputGroupInput\n          ref={inputRef}\n          id={id}\n          type='text'\n          placeholder='Type something...'\n          value={value}\n          onChange={e => setValue(e.target.value)}\n        />\n        {value && (\n          <InputGroupAddon align='inline-end'>\n            <Button\n              variant='ghost'\n              size='icon'\n              onClick={handleClearInput}\n              className='text-muted-foreground hover:bg-transparent'\n            >\n              <CircleXIcon />\n              <span className='sr-only'>Clear input</span>\n            </Button>\n          </InputGroupAddon>\n        )}\n      </InputGroup>\n    </div>\n  )\n}\n\nexport default InputClearDemo\n","type":"registry:component","target":"components/shadcn-studio/input/input-36.tsx"}]}