File upload cards
A drop zone with a list of document cards, where the host owns validation, uploads and row actions.
Arraste os documentos aqui
PDF até 15 MB
ou
Choose files or drag them onto the area. The sample keeps them in memory and uploads nothing.
When to use
- To attach one or a few documents to a task, such as the protocol receipt of a petition.
- When each file needs a card with its details, progress and actions (remove, retry, replace).
- In a form step where the file is the main content of the area.
When not to use
- Many files with extra columns per file. Use File upload table.
- One file inside a form row. Use Single file uploader.
- Transfers that the component should run. It does not upload: it reports files and renders what the host gives it.
States
Empty
Arraste os documentos aqui
PDF até 15 MB
ou
With files
Each card shows the name, a description (type, size, progress or an error) and the actions you render. A progress bar shows while isUploading is true.
- peticao-inicial.pdfPDF, 2,4 MB
- procuracao.pdfEnviando… 45%
Arraste os documentos aqui
PDF até 15 MB
Single file
With multiple={false} the drop zone hides once there is a file. Offer a replace action through renderActions and openFileDialog.
- peticao-inicial.pdfPDF, 2,4 MB
Disabled
Arraste os documentos aqui
PDF até 15 MB
ou
Content
- The title says what to attach: “Anexe o comprovante de protocolo”. The description gives the limits: “PDF até 15 MB”.
- Describe each file with real information: “PDF, 2,4 MB”, “Enviando… 45%”. On failure, write the reason and offer Retry.
- Name row actions after the file: “Remover peticao-inicial.pdf”, not “Remover”.
Do and don’t
Anexe o comprovante de protocolo
PDF do protocolo, até 15 MB
ou
Arquivo
Selecione
ou
Accessibility
- The choose control is a native
button;EnterandSpaceopen the picker. The hidden file input is named byinputLabeland is out of the tab order. - Each card’s text sits in a polite live region, so changes to the description (progress, failure) are announced.
- The progress bar is a Progress with the file name as its accessible name and the percentage as its value.
- Drop is a mouse and touch convenience only; the picker covers keyboard use.
- The choose button has a 44px minimum height on small screens and
xssize from thesmbreakpoint (below 44px, above 24px). - Icons are decorative (
aria-hidden). Always put failures in the description too. - Pass
disabledto your own row actions as well; the component does not disable them.
Code
import { FileUploadCards } from "@repo/ui/file-upload-cards";
<FileUploadCards
accept="application/pdf,.pdf"
files={files}
inputLabel="Comprovante de protocolo"
labels={{
chooseFiles: "Escolher comprovante",
description: "PDF até 15 MB",
or: "ou",
title: "Anexe o comprovante de protocolo",
}}
multiple={false}
onFilesSelected={handleFilesSelected}
renderActions={(file) => <RemoveButton file={file} />}
/>;
Props
FileUploadCards| Prop | Type | Default | Description |
|---|---|---|---|
accept | string | — | Value of the input `accept` attribute |
className | string | — | Extra classes for the root. Layout only |
disabled | boolean | — | Blocks the picker and the drop zone |
files | TFile[] | — | Files to list. The component never changes them |
inputLabel | string | — | Accessible name of the hidden file input |
labels | { title: string; description: string; chooseFiles: string; or: string } | — | Title, description, button and separator copy |
multiple | boolean | true | Accepts several files. When false, the drop zone hides once there is a file |
onFilesSelected | (files: File[]) => void | — | Called with the files picked or dropped. Validate and upload them in the host |
renderActions | (file: TFile, actions: { openFileDialog: () => void }) => ReactNode | — | Actions at the end of each row. Receives the file and `openFileDialog` |
FileUploadCard (items of files)| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | Stable identity, independent of the name. Required. |
name | string | — | File name shown on the card. Required. |
description | ReactNode | — | Type, size, progress or error text. |
icon | ReactNode | — | Decorative icon in a 30 by 36px slot. Defaults to a document icon. |
isUploading | boolean | — | Shows the progress bar for this file. |
progress | number | 0 | Percentage from 0 to 100. |
Known issues
| Issue | Effect |
|---|---|
The drop zone changes only its fill (bg-surface) while a file is dragged over it, and the drag handlers sit on the root. |
The highlight is subtle, and a drop anywhere on the root is accepted even outside the dashed area. |
The component does not filter dropped files by accept. |
A dropped file of another type reaches onFilesSelected. The host must validate. |
The file description uses paragraphXxs, which is 10px (text-[0.625rem]), and the file name labelXs (12px). |
Small text for operators in 8 hour sessions on older monitors. Progress and error messages are the hardest to read. |
renderActions receives no disabled state. |
Row actions stay clickable while the zone is disabled unless the host passes disabled to them. |