File Upload

A component for creating drag-and-drop file upload interfaces with support for single or multiple files, custom triggers, and visual feedback during file dragging operations.

Examples

File Upload with Prompt Input

You can combine the file upload component with the Prompt Input component to create a full-featured input component with file upload support. You can try to drop a file to see the visual feedback.

Installation

Copy and paste the following code into your project.

pnpm dlx shadcn-svelte@latest add https://ai-elements.vercel.app/r/prompt-kit-file-upload.json

Component API

FileUpload

PropTypeDefaultDescription
onFilesAdded(files: File[]) => void-Function called when files are added
childrenSnippet-Child components
multiplebooleantrueAllow selection of multiple files
acceptstring-File types to accept (e.g., ".jpg,.png")

FileUploadTrigger

PropTypeDefaultDescription
asChildbooleanfalseUse child element as the trigger
classNamestring-Additional CSS classes
childrenSnippet-Child components
...propsHTMLAttributes<HTMLButtonElement>-All other button props

FileUploadContent

PropTypeDefaultDescription
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All other div props