Attachment
Shows the name, size, preview, and upload state of a file.
Project brief.pdf
278 KBReady
Homepage-preview.png
1 MBReady
Assets.zip
3 MBReady
attachment-basic-demo.tsx
Installation
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
npm
yarn
pnpm
bun
Composition
AttachmentListAnimates rows in and out.
AttachmentRepeats
Adding and removing files
Check the type and size of each file before you add it. Also install Drop zone and File trigger.
Add files to a support request
PNG, JPEG, or PDF up to 5 MB each
attachment-demo.tsx
Upload states
Project brief.pdf
278 KBUploading 0%
Homepage-preview.png
1 MBUploading 0%
Assets.zip
3 MBUploading 0%
attachment-upload-demo.tsx
API reference
AttachmentList
- children: ReactNodeRequired
- Attachment items. Give each one a unique key.
Attachment
- name: stringRequired
- Filename shown in the row.
- fileSize: number
- File size in bytes.
- previewUrl: string
- Image preview URL. Without it, the row shows a file icon.
- status: "ready" | "uploading" | "complete" | "error" = "ready"
- Upload state. Your app sets it.
- progress: number
- Upload percentage from 0 to 100. The status text shows it. Without it, the progress bar is indeterminate.
- errorMessage: string = "Could not upload"
- Message shown when status is error.
- onRemove: () => void
- Shows a remove button and handles its press.
- onRetry: () => void
- Shows a retry button when status is error.