{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-upload-2",
  "title": "Inline File Field",
  "description": "Compact inline file upload form field with a bordered Choose File row and one attachment showing the selected file name, size, and remove action.",
  "dependencies": [
    "@base-ui/react"
  ],
  "registryDependencies": [
    "attachment",
    "field"
  ],
  "files": [
    {
      "path": "registry/blocks/file-upload/2/file-upload-block.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport {\n  Attachment,\n  AttachmentAction,\n  AttachmentActions,\n  AttachmentContent,\n  AttachmentDescription,\n  AttachmentMedia,\n  AttachmentTitle,\n} from \"@/components/ui/attachment\"\nimport {\n  Field,\n  FieldDescription,\n  FieldGroup,\n  FieldLabel,\n} from \"@/components/ui/field\"\nimport { cn } from \"@/lib/utils\"\nimport { IconPlaceholder } from \"@/components/icons/icon-placeholder\"\n\nconst DEMO_FILE = {\n  name: \"project-brief.pdf\",\n  size: \"1.8 MB\",\n}\n\nexport default function FileUploadBlock() {\n  const [file, setFile] = useState<{ name: string; size: string } | null>(\n    DEMO_FILE\n  )\n\n  function handleRemove() {\n    setFile(null)\n  }\n\n  return (\n    <section className=\"flex w-full items-center justify-center bg-background px-6 py-12 text-foreground\">\n      <div className=\"w-full max-w-sm\">\n        <FieldGroup>\n          <Field>\n            <FieldLabel htmlFor=\"attachment\">Attachment</FieldLabel>\n\n            <div className=\"flex items-center overflow-hidden rounded-lg border border-border bg-background\">\n              <span className=\"flex size-8 shrink-0 items-center justify-center border-r border-border bg-muted text-muted-foreground\">\n                <IconPlaceholder\n                  lucide=\"Paperclip\"\n                  tabler=\"IconPaperclip\"\n                  hugeicons=\"Attachment01Icon\"\n                  phosphor=\"Paperclip\"\n                  remixicon=\"RiAttachmentLine\"\n                  className=\"size-4\"\n                  aria-hidden=\"true\"\n                />\n              </span>\n\n              <span\n                className={cn(\n                  \"min-w-0 flex-1 truncate px-3 text-xs\",\n                  file ? \"text-foreground\" : \"text-muted-foreground\"\n                )}\n              >\n                {file ? file.name : \"No file chosen\"}\n              </span>\n\n              <label\n                htmlFor=\"attachment\"\n                className=\"inline-flex h-8 shrink-0 cursor-pointer items-center border-l border-border bg-muted px-3 text-xs font-medium text-foreground transition-colors select-none hover:bg-muted/70\"\n              >\n                Choose File\n              </label>\n\n              <input\n                id=\"attachment\"\n                type=\"file\"\n                accept=\".pdf,.png,.jpg,.docx\"\n                className=\"sr-only\"\n                onChange={(e) => {\n                  const picked = e.target.files?.[0]\n                  if (picked) {\n                    const kb = picked.size / 1024\n                    const size =\n                      kb >= 1024\n                        ? `${(kb / 1024).toFixed(1)} MB`\n                        : `${Math.round(kb)} KB`\n                    setFile({ name: picked.name, size })\n                  }\n                  e.target.value = \"\"\n                }}\n              />\n            </div>\n\n            <FieldDescription>\n              Accepted: PDF, PNG, JPG, DOCX. Max 10 MB.\n            </FieldDescription>\n\n            {file && (\n              <Attachment state=\"done\" size=\"sm\" className=\"w-full\">\n                <AttachmentMedia>\n                  <IconPlaceholder\n                    lucide=\"File\"\n                    tabler=\"IconFile\"\n                    hugeicons=\"FileIcon\"\n                    phosphor=\"File\"\n                    remixicon=\"RiFileLine\"\n                    aria-hidden=\"true\"\n                  />\n                </AttachmentMedia>\n                <AttachmentContent>\n                  <AttachmentTitle>{file.name}</AttachmentTitle>\n                  <AttachmentDescription className=\"tabular-nums\">\n                    {file.size}\n                  </AttachmentDescription>\n                </AttachmentContent>\n                <AttachmentActions>\n                  <AttachmentAction\n                    aria-label=\"Remove file\"\n                    onClick={handleRemove}\n                  >\n                    <IconPlaceholder\n                      lucide=\"X\"\n                      tabler=\"IconX\"\n                      hugeicons=\"Cancel01Icon\"\n                      phosphor=\"X\"\n                      remixicon=\"RiCloseLine\"\n                      aria-hidden=\"true\"\n                    />\n                  </AttachmentAction>\n                </AttachmentActions>\n              </Attachment>\n            )}\n          </Field>\n        </FieldGroup>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/blocks/file-upload-2.tsx"
    }
  ],
  "meta": {
    "height": "231px",
    "tier": "free"
  },
  "categories": [
    "file-upload"
  ],
  "type": "registry:block"
}