File Item
One file as a row — a picked File or a stored document — with its icon or thumbnail, name, size or date, actions, and an upload status with progress that screen readers hear without the chatter.
FileItem shows one file as a row: an icon or a thumbnail, the name, a meta line with the size and date, and the buttons that go with it. The same row works for a File the visitor just picked and for a document your server stores, so a list of uploads and a list of a student's documents look alike. FileUpload renders its file list with it.
import { FileItem } from '@42-central/ui-react/file-item';
<FileItem file={file} onRemove={() => remove(file)} />A picked file
Pass a File. The name, the size (formatted for the IntlProvider locale) and the icon all come from it; the icon follows the file's kind, read from its type or, when the browser reports none (it often doesn't for .csv or .docx), from its extension. onRemove adds the × button, named "Remove grades.csv" for screen readers.
Code
const [files, setFiles] = useState<File[]>([]);
{files.map((file) => (
<FileItem
key={`${file.name}-${file.lastModified}`}
file={file}
onRemove={() => setFiles((current) => current.filter((f) => f !== file))}
/>
))}
<FileTrigger multiple onSelect={(picked) => setFiles((current) => [...current, ...picked])}>
Add files
</FileTrigger>A stored document
A document on your server isn't a File: describe it with { name, size?, type?, date?, src? }. The date (a Date, a timestamp or an ISO string) shows after the size, as a medium date in the provider's locale and time zone. actions holds your buttons; give each an accessible name that includes the file, since a page of "Download" buttons is otherwise impossible to tell apart.
Code
<FileItem
file={{
name: 'internship-agreement-signed.pdf',
size: 248_213,
type: 'application/pdf',
date: document.signedAt,
}}
actions={
<>
<Button variant="outline" color="neutral" size="xs" aria-label={`View ${name}`}>
View
</Button>
<ActionIcon variant="subtle" color="neutral" size="xs" aria-label={`Download ${name}`}>
<Download className={iconStroke} aria-hidden />
</ActionIcon>
</>
}
/>A date-only ISO string ("2026-10-01") is midnight UTC, which reads as the day before west of UTC. Pass a full timestamp, or replace the line with meta (the size and date go, the status stays):
<FileItem file={document} meta={`Signed by ${document.signer}`} />A list of documents
asChild makes the row your element, so a list of documents can be a real list: screen readers announce it as one, with its length.
- parental-consent.pdf413 kB Aug 28, 2026
- work-experience-report.docx88.1 kB Sep 2, 2026
- attendance-september.xlsx23.9 kB Oct 1, 2026
- id-photo.jpg1.2 MB Jul 19, 2026
Code
<ul className="flex flex-col gap-2">
{documents.map((document) => (
<FileItem key={document.id} asChild file={document} actions={<DownloadButton document={document} />}>
<li />
</FileItem>
))}
</ul>The photo shows its src as a thumbnail. Images and src thumbnails load lazily and fall back to the kind icon if they fail; a picked image File gets an object URL, revoked when the row goes. Pass thumbnails={false} to show kind icons only and make no object URLs, for a list of hundreds of photos.
An object URL has your app's origin. The <img> never runs an SVG's script, but "Open image in new tab" on the thumbnail would, as your app. So a picked File goes through useObjectUrl: a PNG, JPEG, GIF, WebP, AVIF or BMP is re-wrapped under that type, an SVG is drawn from a data: URL (opaque origin, up to SVG_DATA_URL_LIMIT, 5 MB), and any other type shows the kind icon. A descriptor's src is your server's URL, shown as it is: see FilePreview's Security section for the headers to send.
Upload status
status takes a file through an upload: idle, queued, uploading, processing, then done or error. progress (from 0 to 1) fills the bar while uploading. Without a progress, the bar is indeterminate, as it is while processing. An error replaces the meta line with your message, and onRetry adds a Retry button next to it.
Code
<FileItem file={file} status="idle" />
<FileItem file={file} status="queued" />
<FileItem file={file} status="uploading" progress={0.42} />
<FileItem file={file} status="processing" />
<FileItem file={file} status="done" />
<FileItem file={file} status="error" error="The server is unreachable." onRetry={retry} />While the file is queued or in flight, the × button is named "Cancel upload of …" instead of "Remove …", and calls onCancel (falling back to onRemove). Wire both: onCancel stops the upload, onRemove drops a settled file. useFileQueue hands you all of these through itemProps.
Driving it from an upload
FileItem doesn't upload anything: you feed it the state of yours, or let useFileQueue run the uploads and spread its itemProps(id). Here a fake queue uploads two files at a time, and the third fails once at 60%. Press Upload, then Retry.
Code
<FileItem
file={upload.file}
status={upload.status}
progress={upload.progress}
error={upload.error}
onRetry={() => retry(upload)}
onRemove={() => cancel(upload)}
/>Pass status from the first render, "idle" or "queued": the status region screen readers listen to only exists once there is a status, and it speaks up on changes, not on the status it starts with. See Accessibility.
Icons
icons replaces any default icon, by kind (image, video, audio, pdf, text, archive, spreadsheet, document, code, font, other) or by button (remove, retry, done). An icon you pass is drawn as given; add the kit's iconStroke class to keep its 1.5px line.
Code
import { iconStroke } from '@42-central/ui-react';
const icons = {
pdf: <FileBadge className={iconStroke} aria-hidden />,
document: <Presentation className={iconStroke} aria-hidden />,
code: <FileCode2 className={iconStroke} aria-hidden />,
};
<FileItem icons={icons} file={{ name: 'certificate.pdf', size: 98_000 }} />In another language
Every string goes through translations, and a partial override keeps the English default for the rest. Sizes, dates and the percentage come from the IntlProvider locale, so French reads "1,23 Mo · 1 oct. 2026" and "68 %" with no extra work. Here 23:30 UTC on September 30th is already October 1st in Paris.
Code
const FR: FileItemTranslations = {
remove: (name) => `Retirer ${name}`,
cancel: (name) => `Annuler l'envoi de ${name}`,
retry: 'Réessayer',
queued: 'En attente',
processing: 'Traitement…',
done: 'Envoyé',
failed: "Échec de l'envoi",
announcement: (status, name) =>
status === 'uploading'
? `Envoi de ${name}`
: status === 'done'
? `${name} envoyé`
: `Échec de l'envoi de ${name}`,
};
<IntlProvider locale="fr-FR" timeZone="Europe/Paris">
<FileItem translations={FR} file={{ name: 'convention-de-stage.pdf', size: 1_234_567, date }} />
<FileItem translations={FR} file={releve} status="uploading" progress={0.68} />
<FileItem translations={FR} file={attestation} status="error" error="Le serveur ne répond pas." onRetry={retry} />
</IntlProvider>Right-to-left
The row is laid out with logical properties, so an RTL locale mirrors it: the icon on the right, the buttons on the left, the bar filling from the right. Numbers use the locale's digits.
Code
<IntlProvider locale="ar-EG">
<div dir="rtl" lang="ar">
<FileItem translations={AR} file={certificate} onRemove={remove} />
<FileItem translations={AR} file={transcript} status="uploading" progress={0.35} />
</div>
</IntlProvider>Parts
For a layout of your own, compose the parts inside FileItem.Root, which takes the file, the status and the overrides. FileItem.Name takes asChild to become your link. The parts render whenever you place them, except FileItem.Progress, which only shows while uploading or processing: gate FileItem.Retry on the error yourself.
Code
<FileItem.Root file={syllabus}>
<FileItem.Preview />
<FileItem.Body>
<FileItem.Name asChild>
<a href={syllabus.url}>{syllabus.name}</a>
</FileItem.Name>
<FileItem.Meta />
<FileItem.Progress />
</FileItem.Body>
<FileItem.Actions>
<DownloadButton />
</FileItem.Actions>
</FileItem.Root>| Part | Renders |
|---|---|
FileItem.Root | The row, and the status region. Takes file, status, progress, error, disabled, thumbnails, icons, translations. |
FileItem.Preview | The thumbnail or the kind icon. Hidden from assistive tech: the name is right next to it. |
FileItem.Body | The name, meta and progress column, aria-busy while the file uploads or is processed. |
FileItem.Name | The name on one line, truncated by CSS only, with the full name in a title. |
FileItem.Meta | Size and date (or its children), then the status. An error replaces the line. |
FileItem.Progress | The bar, only while uploading or processing. |
FileItem.Actions | Your buttons. |
FileItem.Retry | A small Retry Button, described by the file name. |
FileItem.Remove | The × button, named after the file. |
Helpers
The row's formatting is exported for your own cells and messages: formatFileSize and fileKind.
import { fileKind, formatFileSize, useLocale } from '@42-central/ui-react';
formatFileSize(document.size, useLocale()); // "248 kB", "248 ko"
fileKind('', 'grades.csv'); // "spreadsheet"API
Prop
Type
Accessibility
- The row reads in order: name, size and date, status, then its buttons. The thumbnail or icon is hidden from assistive tech, since the name beside it says the same thing.
- The name is truncated by CSS only: the full name stays in the text screen readers read, and in a
titlefor the pointer. - The × button is named after the file ("Remove cv.pdf"), and "Cancel upload of cv.pdf" while it is queued or in flight. Retry is described by the file name ("Retry, cv.pdf").
- The upload bar is a
role="progressbar"named after the file, witharia-valuenowwhile uploading; while processing it is indeterminate, with the value text "Processing…". The name and meta column isaria-busymeanwhile. - With a
status, the row keeps a politerole="status"region. It speaks when an upload starts ("Uploading cv.pdf"), ends ("cv.pdf uploaded") or fails ("cv.pdf failed to upload", then yourerror), never for the status the row mounts with and never per progress tick. It sits outside the busy column, so it isn't held back while the column is busy. - A row fed by a
useFileQueue({...queue.itemProps(id)}) has no region:itemPropspassesannounce: false, and oneFileQueueSummaryspeaks for the whole upload, so 400 rows don't make 800 announcements. Passannounceafter the spread to bring a row's own back. - Status is never color alone: done says "Uploaded" next to its check, and an error shows its message.
- RTL follows the locale, through
IntlProvider.
Changelog
- #366
New
FileItem: one row for a pickedFileor a stored document — thumbnail or kind icon, size, date, uploadstatus/progress,onRetry,onRemove/onCancel, polite announcements and composable parts; thumbnails render only for allowlisted types - #366
formatFileSize(bytes, locale?)andfileKind(type, name)are exported
FileTrigger
A button that opens the file picker, or a phone's camera, and hands you the picked files. No dropzone and no file list, so any Button or ActionIcon can become one.
Slider
Single-value or two-thumb range input on top of Ark UI's slider primitives. Field label, marks, floating thumb label, sizes, colors — keyboard, RTL, and ARIA handled upstream.