Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

File Embed

ProNew

Share supplied files as a list, boxed rows, preview-card grid or inline viewer, with type icons, sizes, download links and a popup for PDFs and images.

Installation

pnpm dlx shadcn@latest add @viewport/file-embed

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
files*EmbedFile[]—
layout"viewer" | "list" | "grid"

`viewer` shows one file inline, `list` and `grid` show them all.

"list"
titlestring

Optional heading above the files.

—
rows"plain" | "boxed"

Row style of the list layout.

"plain"
columns2 | 3 | 4

Most columns the grid may use; it drops columns as the container narrows.

3
action"preview" | "link" | "download"

What choosing a file does: open the preview popup, open the link, or download.

"preview"
iconsboolean

Show the type icon.

true
sizesboolean

Show the file size.

true
downloadboolean

Show a download control on every file.

true
downloadLabelstring

Text of the download control in grid and boxed rows.

"Download"
viewerHeightnumber

Height of the inline viewer, in pixels.

560
loadingboolean

Shows placeholders while the file list is being fetched.

false
emptyTextstring

Shown when there are no files.

"No files have been shared yet."
onOpen(file: EmbedFile) => void—
onDownload(file: EmbedFile) => void—
classNamestring—

Accessibility

  • Files with safe links remain real, named links; invalid links are omitted and their count announced instead of creating unsafe actions.
  • The preview popup is a dialog that traps focus, closes with Escape and returns focus to the file you chose; panel and backdrop enter together.
  • In the viewer layout files are tabs: Left, Right, Home and End move between them.
  • Type icons are decorative; the type is also written in the line under the name.
  • Loading is announced as a status, and files with no preview say so and offer the download.