Skip to content
Playground

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.

research-notes.pdf
PDF · 2.4 MB
product-review.pptx
Uploading68%
Uploading
TSX
import { FileCard, fileTypeFromName } from "@zentara-co/zenos-ui";

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.

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.

TSX
<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>

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.

Turquoise lake surrounded by mountains
moraine-lake.jpg
4.8 MB · 2400 × 1600
Close-up of a computer circuit board
circuit-closeup.jpg
2.1 MB · 3000 × 2000

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.

research.pdf
pdf
project-brief.docx
document
forecast.xlsx
spreadsheet
launch-deck.pptx
presentation
brand-assets.zip
archive
component.tsx
code
TSX
const type = fileTypeFromName(file.name); <FileCard.Icon type={type} label={file.extension.toUpperCase()} />;

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.

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.

launch-film.mp4
Uploading 12.6 of 30 MB
42%
Uploading
forecast.xlsx
Upload complete · 940 KB
Upload complete
source-files.zip
Upload failed
Upload failed

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.

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.

default surface
Document · 620 KB
outline surface
Document · 620 KB
elevated surface
Document · 620 KB
ghost surface
Document · 620 KB
white surface
Document · 620 KB

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.

accessibility-audit.pdf
Open file · PDF · 1.8 MB
meeting-notes.docx
DOCX · 340 KB

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.

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.

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.

tokens.json
JSON · Updated just now

Variants

defaultoutlineelevatedghostwhite
FileCard.Root
FileCard.Icon
FileCard.Thumbnail
FileCard.Content
FileCard.Name
FileCard.Meta
FileCard.Value
FileCard.Actions
FileCard.Progress
FileCard.Status

API

PropTypeDefaultDescription
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-*.

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.

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.