File Card
A composed attachment surface for file identity, metadata, actions, upload progress, and status.
File Card represents one file with its identity, metadata, upload state, and related actions. Compose rows into attachment lists or use tiles in upload trays and media browsers.
Import
Section titled “Import”import { FileCard, fileTypeFromName } from "@zentara-co/zenos-ui";When to use
Section titled “When to use”Use File Card when the file itself is the object a user needs to inspect, upload, open, download, retry, or remove. It is well suited to message attachments, form uploads, import queues, and lightweight file browsers.
Use Thumbnail when the media preview is the primary object and you only need preview or remove behavior. Use File Tree for hierarchical navigation. Use a standard Card when the content is not specifically a file.
Anatomy
Section titled “Anatomy”Use either FileCard.Icon for a file-type illustration or FileCard.Thumbnail for visual media. Content groups the name, metadata, and optional progress bar; status and actions remain trailing siblings so the row stays easy to scan.
<FileCard> <FileCard.Icon type="pdf" /> <FileCard.Content> <FileCard.Name>research.pdf</FileCard.Name> <FileCard.Meta>PDF · 2.4 MB</FileCard.Meta> </FileCard.Content> <FileCard.Actions>{/* icon buttons */}</FileCard.Actions></FileCard>File illustration and thumbnail
Section titled “File illustration and thumbnail”FileCard.Icon provides a built-in document illustration for common file families. The File Icons page lists every family, its tone, and the extensions fileTypeFromName recognizes. Derive the type from a filename with fileTypeFromName(name), or set type explicitly when the MIME type is more reliable. Use label only when a product-specific extension needs a different short name.
Use FileCard.Thumbnail when the image itself helps someone recognize the file. Its alt prop is required: describe useful visual content, or use the filename when that is the clearest available label.
Derive a file type from its name
Section titled “Derive a file type from its name”fileTypeFromName recognizes common document, spreadsheet, presentation, archive, image, video, audio, and source-code extensions. It normalizes letter case and returns "default" for an unknown or extensionless filename. Prefer a trusted MIME type when one is already available; filenames can be incomplete or misleading.
const type = fileTypeFromName(file.name); <FileCard.Icon type={type} label={file.extension.toUpperCase()} />;Content hierarchy
Section titled “Content hierarchy”Keep FileCard.Name to the real filename, including its extension. It truncates visually in narrow rows, so preserve the complete name in the DOM and avoid shortening the underlying string.
Use one concise FileCard.Meta line for the information needed to distinguish the file: format, size, modified date, owner, or upload result. Put the most useful facts first and separate them consistently, for example PDF · 2.4 MB. Do not repeat the filename, progress percentage, or status text in the meta line.
Upload states
Section titled “Upload states”Set state on the root so FileCard.Progress and FileCard.Status stay synchronized. Uploading shows activity, success confirms completion, and error applies a danger surface and progress color. Keep a failed upload in place so the user can identify it and retry or remove it.
FileCard.Progress renders its percentage by default. Set hideValue when FileCard.Value displays that number elsewhere in the row; do not announce the same percentage twice.
For a live upload, keep value between 0 and 100 and update the same mounted card instead of replacing it on every tick. Move to state="success" only after the server confirms completion. For an error, replace progress detail with an actionable reason when available and place retry or remove controls in FileCard.Actions.
Layout, density, and variants
Section titled “Layout, density, and variants”The default layout="row" is best for attachment lists and form uploads. Use layout="tile" when previews are the primary scanning cue. density="compact" reduces the card and media dimensions for dense trays; when omitted, density inherits from DensityProvider.
Choose default for most product surfaces, outline for flatter groups, elevated when the file needs stronger separation, and ghost when a surrounding container already provides the surface.
Use variant="white" for a white attachment surface in light mode and the default card background in dark mode. It uses background-default in light mode and background-neutral-card in dark mode, with names, metadata, icons, and status text following the active theme. Error-state styling takes precedence over this fill.
Interaction model
Section titled “Interaction model”Keep the root non-interactive when it contains download, remove, overflow, or retry controls in FileCard.Actions. This preserves separate keyboard targets and clear action names.
When the whole card has exactly one destination, render it as a native link with as="a", provide href, and set interactive. Do not nest buttons or links inside an interactive root.
Actions
Section titled “Actions”Prefer icon buttons for familiar, repeated actions in attachment lists. Give every icon-only action a file-specific accessible name such as “Download research notes” rather than “Download.” Keep destructive removal separate from opening the file, and confirm removal only when recovery is difficult or the effect extends beyond the current draft.
Avoid hiding essential actions only on hover. Touch, keyboard, zoomed, and reduced-pointer interfaces must retain a discoverable way to reach them.
Responsive behavior
Section titled “Responsive behavior”Rows should remain the default on narrow screens. Let the filename and metadata truncate while media, status, and actions keep their usable size. When a row cannot accommodate several trailing controls, move secondary actions into a labeled overflow menu rather than shrinking the touch targets.
For tile collections, let the parent grid decide the column count. File Card owns its internal tile layout, not the width of the collection.
Custom styling
Section titled “Custom styling”Every part exposes a stable data-slot, and className merges last. Prefer semantic surface, border, text, and icon tokens so customization remains legible in light and dark themes.
Variants
defaultoutlineelevatedghostwhite FileCard.Root FileCard.Icon FileCard.Thumbnail FileCard.Content FileCard.Name FileCard.Meta FileCard.Value FileCard.Actions FileCard.Progress FileCard.Status
API
| Prop | Type | Default | Description |
|---|---|---|---|
variant | default | outline | elevated | ghost | white | default | Surface treatment for the file attachment. |
layout | row | tile | row | Horizontal attachment row or vertical media tile. |
state | idle | uploading | success | error | idle | Upload lifecycle consumed by Progress and Status. |
density | comfortable | compact | comfortable | Controls spacing and media size. Inherits from DensityProvider when omitted. |
interactive | boolean | false | Adds focus, hover, and pointer affordances for an interactive root. |
as | ElementType | div | Renders the root as a semantic element such as an anchor or button. |
Icon.type | default | pdf | document | spreadsheet | presentation | archive | image | video | audio | code | default | File family controlling the built-in illustration label and semantic tint. |
Icon.label | string | — | Overrides the short extension label in the built-in illustration. |
Thumbnail.alt | string | — | Required alternative text for an image thumbnail. |
Progress.value | number | — | Upload percentage, clamped visually between 0 and 100. |
Progress.label / hideValue | ReactNode / boolean | Uploading / false | Progress caption and control for the internal percentage label. |
Status.status | idle | uploading | success | error | — | Overrides the nearest root state. Idle renders nothing. |
native props | React.HTMLAttributes<HTMLElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |
Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props,
including className, style, aria-*, and data-*.
Accessibility
Section titled “Accessibility”Use a real button or link for each action and give icon-only controls a specific accessible name such as “Download research notes.” FileCard.Status includes polite status text for the current lifecycle state, while FileCard.Progress exposes native progressbar semantics and the current numeric value.
The built-in file illustration is decorative because the filename carries the identity. Image thumbnails require useful alternative text. Avoid making a card interactive when its content already contains controls, and keep visible focus on whole-card links or buttons.
Review checklist
Section titled “Review checklist”Before shipping a File Card experience, verify:
- The complete filename and extension remain available to users.
- Metadata is concise and does not repeat the filename or progress value.
- The illustration type comes from a trusted MIME type or a safely derived extension.
- Meaningful thumbnails have accurate alternative text.
- Upload progress has one visible percentage and a useful label.
- Success appears only after the upload is confirmed.
- Failed files remain identifiable and offer an appropriate retry or removal path.
- Whole-card interaction uses a native link or button and contains no nested controls.
- Separate icon actions have file-specific accessible names.
- Keyboard focus remains visible in light and dark themes.
- Narrow layouts preserve readable content and usable action targets.