A file input on Vercel's UI SDK with a drop zone, paste, type and size checks, rejected files with reasons, image previews and form support.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
npm packages it adds
- cn
- @ui-sdk/core
- @ui-sdk/react
- @tabler/icons-react
- class-variance-authority
Code
import {
FileInput,
FileInputDropzone,
FileInputDropzoneDescription,
FileInputDropzoneIcon,
FileInputDropzoneTitle,
FileInputItem,
FileInputList,
FileInputRejections,
FileInputTrigger,
} from "@/components/ui/ui-sdk-file-input"
function UiSdkFileInputDemo() {
return (
<FileInput
multiple
accept={["image/*", ".pdf"]}
maxFiles={5}
maxSize={5_000_000}
className="max-w-md"
>
<FileInputDropzone>
<FileInputDropzoneIcon />
<FileInputDropzoneTitle>Drop files here</FileInputDropzoneTitle>
<FileInputDropzoneDescription>
Images or PDFs, up to 5 files of 5 MB each. You can paste them too.
</FileInputDropzoneDescription>
<FileInputTrigger className="mt-3">Browse files</FileInputTrigger>
</FileInputDropzone>
<FileInputRejections />
<FileInputList aria-label="Files">
<FileInputItem />
</FileInputList>
</FileInput>
)
}
export { UiSdkFileInputDemo }
































