{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "search-field",
  "type": "registry:component",
  "title": "Search field",
  "description": "An accessible, controlled search input with a search icon and keyboard-friendly clear action.",
  "categories": [
    "forms"
  ],
  "dependencies": [
    "@tabler/icons-react"
  ],
  "registryDependencies": [
    "input"
  ],
  "files": [
    {
      "path": "src/registry/overtrue/search-field.tsx",
      "type": "registry:component",
      "target": "components/overtrue/search-field.tsx",
      "content": "\"use client\";\nimport { useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { IconSearch, IconX } from \"@tabler/icons-react\";\nimport { Input } from \"@/components/ui/input\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SearchFieldProps extends Omit<\n  ComponentProps<typeof Input>,\n  \"type\" | \"value\" | \"defaultValue\" | \"onChange\"\n> {\n  label: string;\n  value: string;\n  onValueChange: (value: string) => void;\n  containerClassName?: string;\n}\n/** Controlled search input. Filtering and debouncing belong to the caller. */\nexport function SearchField({\n  label,\n  value,\n  onValueChange,\n  id,\n  ref,\n  containerClassName,\n  className,\n  placeholder = \"Search…\",\n  ...props\n}: SearchFieldProps) {\n  const generatedId = useId();\n  const inputId = id ?? generatedId;\n  const inputRef = useRef<HTMLInputElement>(null);\n  useImperativeHandle(ref, () => inputRef.current!, []);\n  return (\n    <div\n      data-slot=\"search-field\"\n      className={cn(\"relative min-w-0\", containerClassName)}\n    >\n      <label htmlFor={inputId} className=\"sr-only\">\n        {label}\n      </label>\n      <IconSearch\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground\"\n      />\n      <Input\n        {...props}\n        ref={inputRef}\n        id={inputId}\n        type=\"search\"\n        value={value}\n        onChange={(event) => onValueChange(event.target.value)}\n        placeholder={placeholder}\n        className={cn(\n          \"h-10 w-full rounded-md border-input bg-card dark:bg-card ps-9 pe-9 text-base text-foreground shadow-xs placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20 sm:text-sm [&::-webkit-search-cancel-button]:appearance-none\",\n          className,\n        )}\n      />\n      {value && !props.readOnly && (\n        <button\n          type=\"button\"\n          aria-label={`Clear ${label.toLowerCase()}`}\n          disabled={props.disabled}\n          className=\"absolute end-1 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"\n          onClick={() => {\n            onValueChange(\"\");\n            inputRef.current?.focus();\n          }}\n        >\n          <IconX aria-hidden=\"true\" className=\"size-3.5\" />\n        </button>\n      )}\n    </div>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/search-field. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
