File Card

Pro

A card for a single file: a realistic file-type illustration or image thumbnail, the name, a meta line, trailing actions and an optional progress bar. Composes into attachment rows and upload trays.

Annual report 2025.pdf
2.4 MB · PDF document
hero-banner.png
880 KB · Uploaded
q3-forecast.xlsx

Installation#

# One-time setup (tokens + lib helpers)npx koalaui-cli@latest init# Activate your Pro license (once per machine)npx koalaui-cli@latest login <key># Add this component (its dependencies come along)npx koalaui-cli@latest add file-card

Usage#

File Card is composed from named parts, like Card. The FileCard root owns the surface, variant, state, and density; the parts (FileCardIcon, FileCardName, FileCardProgress) read it from context.

This example is part of Koala UI Pro

The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.

Have a license? Unlock it here

Anatomy#

import {  FileCard,  FileCardIcon,  FileCardThumbnail,  FileCardContent,  FileCardName,  FileCardMeta,  FileCardProgress,  FileCardValue,  FileCardActions,  FileCardStatus,} from "@/components/ui/file-card"<FileCard>  <FileCardIcon />  <FileCardThumbnail />  <FileCardContent>    <FileCardName />    <FileCardMeta />    <FileCardProgress />  </FileCardContent>  <FileCardValue />  <FileCardActions />  <FileCardStatus /></FileCard>

A row reads left-to-right: a FileCardIcon (or FileCardThumbnail) leads, a FileCardContent column fills with the FileCardName over a muted FileCardMeta line, and FileCardActions ride the right edge. The name truncates so a long filename never pushes the actions off the card.

Annual report 2025.pdf
2.4 MB · PDF document

File types#

Pass type to FileCardIcon and it renders a realistic file illustration: a sheet with a dog-eared corner and a colored band stamped with the extension. The tone re-themes across all four palettes: PDFs read red, images purple, sheets green, and so on. The band shows a short stand-in (PDF, XLS, IMG…) by default; pass label to stamp the real extension (the demo below shows DOCX, XLSX, TSX). Don’t know the type up front? Derive it from the filename with fileTypeFromName(file.name). The illustration is FileIcon, also usable on its own: every extension, its soft and solid variants and SVG downloads live on File Icons.

document.pdf
pdf
photo.png
image
clip.mp4
video
track.mp3
audio
letter.docx
doc
budget.xlsx
sheet
deck.pptx
slides
assets.zip
archive
index.tsx
code
notes.txt
text

Thumbnail#

For images, swap the glyph tile for a FileCardThumbnail. It fills the same footprint, clips the preview to the concentric radius, and carries a subtle inset outline so the image edge reads cleanly on any surface. Always pass a meaningful alt.

Mountain landscape
mountain-vista.jpg
1.8 MB · 2400 × 1600
Circuit board
circuit-closeup.jpg
2.1 MB · 3000 × 2000

Tile layout#

Same card, second arrangement. Pass layout="tile" and the row becomes the square cell of an image grid: the FileCardThumbnail fills it edge to edge and FileCardActions become a blurred scrim that fades in on hover or keyboard focus. The tile itself never moves - no lift, no press scale - so the photo and the wash carry the whole interaction. Pair it with File Upload’s FileUploadGrid.

A-frame cabin among autumn trees
Lakeside cabin at dusk
Sunlit forest canopy

Upload progress#

Drop a FileCardProgress into the content column to show an in-flight upload. It renders the DS Progress bar, so a live value animates smoothly, the percentage uses tabular-nums, and the bar re-tones to destructive when the card’s state is error. Swap it for a FileCardMeta once the upload lands.

The readout is droppable. Leave it in and the label and percentage sit above the bar; pass hideValue and move the number out to a FileCardValue beside the content column, and the bar runs the full width with the percentage holding the row’s right edge.

product-demo.mp4
Uploading…
product-demo.mp4
0%

States#

The root state drives the surface and the trailing FileCardStatus glyph: uploading spins, success lights a green check, and error pulls a soft destructive border with a warning so a failed file reads at a glance.

contract-draft.docx
Uploading…
contract-final.docx
312 KB · Uploaded
contract-broken.docx
File exceeds the 10 MB limit

Variants#

default sits on a hairline border with a soft shadow; outline drops the shadow for flat, gridded lists; elevated trades the border for a lifted shadow when a card needs to float; ghost strips all chrome and padding so the row sits flush in feeds, comment threads, and dense lists. The file illustration still carries the file’s identity.

brand-guidelines.pdf
default
brand-guidelines.pdf
outline
brand-guidelines.pdf
elevated
brand-guidelines.pdf
ghost

Density#

Density is Koala’s cross-cutting spacing axis (see Density). For File Card it tunes padding, gap, and the media tile. compact is the dense app default for upload trays and file lists; comfortable is roomier. Set it per-card or for a whole list with DensityProvider.

design-assets.zip
compact
design-assets.zip
comfortable

Interactive#

A file row is inert by default. When the whole card should open the file, pass asChild to render it as a link and interactive to add the pointer, hover lift, and focus ring. For per-file actions instead, keep the card inert and drop Buttons into FileCardActions.

API reference#

FileCard

The root: owns the surface, layout, state and density, and shares them with every part through context. Forwards all native <div> props; every part accepts className, merged last.

PropTypeDefaultDescription
layout"row" | "tile""row"row is the attachment line; tile is a square image-grid cell where the thumbnail fills the card and the actions become a hover scrim.
variant"default" | "outline" | "elevated" | "ghost""default"Chrome: an edge ring with a soft lift, a bare --border ring, a filled lifted card, or no chrome and no padding (flush in feeds).
state"idle" | "uploading" | "success" | "error""idle"Upload state, read by FileCardStatus and FileCardProgress; error tints the surface with a soft destructive ring.
density"comfortable" | "compact""compact"Padding, gap and media size (48px or 40px). Falls back to the nearest DensityProvider.
interactivebooleanfalseAdds the pointer, hover lift, press feedback and focus ring for a card that opens the file.
asChildbooleanfalseMerge onto your own element (a link, a button) instead of rendering a <div>.
Data attributeDescription
data-state"idle", "uploading", "success" or "error".
CSS variableDescription
--surfaceSet to var(--card) on elevated, read by nested controls.

FileCardIcon

The leading file illustration, decorative (aria-hidden). Pass children instead of type to put your own glyph in a soft muted tile. Forwards all native <div> props.

PropTypeDefaultDescription
type"pdf" | "image" | "video" | "audio" | "doc" | "sheet" | "slides" | "archive" | "code" | "design" | "text" | "default""default"File category: picks the tone and the default band label. Derive it with fileTypeFromName(name).
labelstring-Text stamped on the band, e.g. the real extension "DOCX". Defaults to the type's stand-in ("PDF", "XLS").

FileCardThumbnail

An image preview in the icon's footprint, clipped to the concentric radius with an inset outline. Forwards all native <img> props to the image.

PropTypeDefaultDescription
alt*string-A meaningful description of the image.

FileCardContent

The column that fills the row and lets the name truncate. Forwards all native <div> props.

FileCardName

The file name, truncated on one line. Forwards all native <div> props.

FileCardMeta

The muted meta line (size, date) in tabular-nums; takes small icons. Forwards all native <div> props.

FileCardValue

A trailing readout (60%, 2.4 MB of 8 MB) placed beside FileCardContent, so a full-width progress bar runs under the name. Forwards all native <div> props.

FileCardActions

Trailing buttons on the row's right edge; in tile layout, a blurred scrim that fades in on hover or focus. Forwards all native <div> props.

FileCardProgress

An upload bar built on Progress (size="sm") with an optional label and percentage above it; it turns destructive when the card's state is error. Forwards native <div> props except children.

PropTypeDefaultDescription
valuenumber0Upload completion, 0 to 100.
labelReact.ReactNode-Leading label above the bar, e.g. "Uploading…".
hideValuebooleanfalseDrop the percentage, typically because a FileCardValue shows it on the row's edge.

FileCardStatus

A trailing status glyph: a spinner, a green check or a warning. Renders nothing while the card is idle. Forwards all native <span> props.

PropTypeDefaultDescription
status"uploading" | "success" | "error"-Override the glyph; by default it follows the card's state.
labelstring-Accessible name when the glyph is the only carrier of the status: it then announces as an image and becomes focusable. Without it the glyph is aria-hidden.

FAQ#

Pass `type` to FileCardIcon to render a realistic file illustration (a sheet with a dog-eared corner and a colored extension band) with a re-themable tint, for example "pdf" reads red and "image" reads purple. If you only have a filename, call `fileTypeFromName(file.name)` and pass its result as the type; it falls back to "default" for unknown or extensionless names. By default the band shows a short per-type stand-in (PDF, XLS, IMG…); pass `label` to stamp the exact extension, e.g. label="CSV".