File
Display one file as a media card or compact row, with file-kind glyphs, upload progress, bookmarking, and overflow actions.
import { FileCard } from '@uthereal/ui/file-card'File card playground
, Document
PDF · 2.4 MB
Overview
FileCard represents one file in a library, attachment gallery, or upload queue. It renders a preview image or file-kind glyph, an opening title, a description, a byline with owner avatar and lifecycle status, an optional bookmark toggle, and an overflow menu.
Use FileCard to display stored files or active uploads. Use File input to pick or drop new files, and Action swap for interactive non-file records such as messages or tasks.
| Layout | Surface structure | Best for |
|---|---|---|
grid | Vertical card with top media preview (112px default height), title, description, owner/status byline, actions. | Media libraries and galleries. |
row | Single 58px compact line with a 40px glyph or thumbnail tile (hides under 300px container width) and end tools. | Attachment lists and queues. |
Usage
'use client'
import { FileCard } from '@uthereal/ui/file-card'
export function LibraryFile({ file, saved, saving, onSave, onRun }: Props) {
return (
<FileCard
title={file.name}
mediaType={file.type}
description={`${file.kind} · ${file.size}`}
meta={file.owner}
status={file.uploading ? 'running' : undefined}
progress={file.percent}
statusText={file.updated}
href={`/library/${file.id}`}
bookmarkable
bookmarked={saved}
bookmarkPending={saving}
onBookmarkedChange={onSave}
menu={[
{
kind: 'action',
id: 'download',
label: 'Download file',
action: 'download_file',
},
{ kind: 'separator', id: 'danger' },
{
kind: 'action',
id: 'delete',
label: 'Delete file',
action: 'delete_file',
destructive: true,
},
]}
onAction={(action, entryId) => onRun(action, file.id, entryId)}
/>
)
}Examples
Card layout
Use layout="grid" (the default) inside a CSS grid for media galleries.
, Video
Video · 48 MB
, Archive
Archive · 12 MB
Row layout
Use layout="row" inside a vertical stack for dense file lists. When a row container narrows below 300px, the leading icon or thumbnail hides automatically.
, Document
, Archive
Status and loading states
Combine status, progress, reason, and loading to show queued, uploading, failed, and placeholder cards in either layout.
Notes.txt, Document
Text · 4 KB
File kinds and status
mediaType / extension | Resolved FileKind | Default glyph | Spoken kind (labels.kinds) |
|---|---|---|---|
image/* (.png, .jpg, .webp, .svg) | image | file-image | Image |
video/* (.mp4, .mov, .webm) | video | file-play | Video |
zip, tar, gzip, archive MIME types | archive | file-archive | Archive |
application/pdf, text/*, .md, .docx | text | file-text | Document |
| Any other MIME type or unknown extension | file | file | File |
status | Visual treatment |
|---|---|
pending | Muted status text (Waiting). |
running | Status text (Uploading or Uploading {percent}) and a 4px spring progress bar when known. |
complete | Secondary status text (Ready) with a drawn check mark (success token). |
error | Danger alert icon and reason (or Failed when omitted); row layout tints the outer border. |
previewSrc replaces the default glyph with a decorative cover image (40px rounded thumbnail in row layout). statusText renders freeform status copy such as "Updated 2 hours ago" with word-by-word rise updates. Switch between grid and row collections using Tabs or Radio.
API reference
Serializable arguments and defaults come directly from fileCardConfigSchema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Untitled file" | The file name, e.g. "Q3 report.pdf"; its extension also picks the glyph when the media type does not. |
description | string— | A line under the title, typically the type and size ("PDF · 2.4 MB"). In the row it leads the meta line. |
meta | string— | Who the file belongs to, in ink beside the avatar in the byline (grid). |
avatar | object— | The owner picture or initials (name, src) at the start of the byline (grid). |
mediaType | stringDefault: "application/octet-stream" | The MIME type, e.g. application/pdf. It picks one of Arc's glyphs: image, video, archive, document (PDF, text, word processing) or file; assistive technology reads the kind after the title. |
previewSrc | string— | A preview image URL: it fills the media in the grid and a 40 px thumbnail in the row; it is decorative, the title names the card. |
href | string— | Open the file at this URL; the title's hit area covers the card. |
action | string— | A host-registered action sent when the card is opened; the title's hit area covers the card. Not with href. |
status | pending | running | complete | error— | Lifecycle in the byline: pending (Waiting), running (Uploading, or the percent over a bar with progress), complete (Ready, with a check) or error (an alert and the reason, or Failed without one). It rolls in when it changes and is announced. Omit it for none. |
progress | number— | Percent done (0–100) while running: shown as "Uploading 42%" and a 4 px bar. |
reason | string— | Why the file failed, shown after the error status (and the row border tints danger). |
statusText | string— | Free status text such as "Updated 2 hours ago"; a new text rolls in word by word, as in Arc's card, and is announced. |
bookmarkable | booleanDefault: false | Show a bookmark toggle; its state is host state with defaultBookmarked as the start. |
defaultBookmarked | booleanDefault: false | Whether the bookmark starts on. |
menu | OverflowMenuItem[]Default: [] | Overflow menu entries, at most 12: kind action (id, label, action, destructive) or kind separator. Actions are sent with the entry id. |
layout | grid | rowDefault: "grid" | grid is Arc's card (media on top, title, description, byline and actions in the footer) for galleries; row is Arc's file row (40 px glyph or thumbnail, name and meta, actions at the end) for lists. |
headingLevel | integerDefault: 3 | Heading level of the title, 2 to 6. |
loading | booleanDefault: false | Show a placeholder card in the same layout and announce loadingLabel. |
loadingLabel | stringDefault: "Loading" | Announced while loading. |
labels | FileCardLabels— | Text: the file kind names (kinds, read after the title), the status labels with the progress template (Uploading {percent}), the bookmark toggle name (Bookmark {title}) and the overflow button name (More actions for {title}). |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | FileCardTheme— | Color mode and accent (passed to the controls), and tokens for colors, type, the control scale, the strong hover edge and raised shadow, the panel radius, success, mediaHeight and tileSize. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | Hover lift and media zoom, status rolls and the progress bar. System reduced-motion preferences take precedence. |
dir | ltr | rtl— | Reading direction; the actions sit at the inline end. Omit it to inherit the page direction. |
OverflowMenuItem entries are either { kind: 'action', id, label, action, destructive? } or { kind: 'separator', id }.
React integration
| Prop | Purpose |
|---|---|
onAction(action, entryId?) | Receives the card open action (no ID) or an overflow menu action with ID. |
bookmarked, onBookmarkedChange | Controlled bookmark state and change callback (fires in both modes). |
bookmarkPending | Marks the action group aria-busy and ignores toggle presses without blur. |
renderIcon(name, { size, slot }) | Replaces the decorative file-kind icon (slot is 'media' or 'tile'). |
preset | Application defaults overridden by explicit instance props. |
tokens | --ui-* CSS variables forwarded to the card and all nested controls. |
ref, className, style, rest | Forwarded to the root <article> element. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Moves between the title link/button, bookmark toggle, and overflow menu trigger. |
Enter, Space | Activates the card title action, toggles bookmarking, or opens the overflow menu. |
Arrow keys, Escape | Navigates and closes the overflow menu, restoring focus to the menu button. |
Each card renders an <article> with the title as a configurable heading (headingLevel, default 3). When href or action is supplied, the title's hit area covers the full card while bookmark and overflow controls sit above it on z-index: 1. Assistive technology reads the file kind after the title, and a pre-mounted role="status" region announces loading and status transitions. In right-to-left (dir="rtl") layouts, actions align to the inline end and progress bars fill from inline start. Under forced-colors: active, borders use ButtonText, progress fills use Highlight, and keyboard focus draws a Highlight outline.
Motion and theming
Hovered grid cards lift 2px on the snappy spring with a raised shadow while media zooms to 1.04; row frames strengthen their border. Status labels rise in, the progress bar slides on the smooth spring, and completion draws the check path. Under prefers-reduced-motion: reduce, hover lift, zoom, and progress-bar transforms stop while border/shadow transitions keep a 120ms fade and statusText swaps immediately. Under motion="none", all hover transforms and transitions disable immediately (0ms).
| Token group / key | Role |
|---|---|
core, control | Card surface, ink, muted byline, icon scale, and nested controls. |
borderStrong, shadowRaised, popupRadius | Card corner radius (26px default) and hover/focus elevation. |
success, danger, accent | Complete check mark, failure state and border tint, progress fill. |
mediaHeight (112), tileSize (40) | grid media area height and row leading tile size in pixels. |
UtherealProvider supplies application-wide defaults. See Motion.
Composition
In agent compositions, FileCard is a leaf component. Register action and every menu entry's action on the host. Bookmark state persists at /components/instance-<id>/bookmarked.
{
"type": "FileCard",
"props": {
"title": "Q3 board report.pdf",
"mediaType": "application/pdf",
"description": "PDF · 2.4 MB",
"meta": "Ada Park",
"status": "complete",
"action": "open_file"
},
"children": []
}