File preview
A file opened for a look: image, page, PDF, video, archive or no preview; arrows to its neighbours.
import { FilePreview, FileDetails } from "@forgeron/ui";Night dock.md
Night dock from week 3 Receiving until 02:00 on dock 3, the only one long enough for semi-trailers. Drivers enter by Gate B.
import { FilePreview } from "@forgeron/ui";
export default function Default() {
return (
<div style={{ width: "100%", maxWidth: 560 }}>
<FilePreview
name="Night dock.md"
size={1_240}
meta="Léa Martin · Nov 17"
text={
"Night dock from week 3\n\nReceiving until 02:00 on dock 3, the only one long enough for semi-trailers.\nDrivers enter by Gate B."
}
onDownload={() => {}}
onClose={() => {}}
/>
</div>
);
}Gate B at night.jpg
1 / 5
// The preview of a folder's files one after the other: the arrows (and ← →) go to the
// neighbours, the details sit beside the stage. Kinds without a source draw a placeholder.
import { FileDetails, FilePreview, type FileKind } from "@forgeron/ui";
import { useState } from "react";
const FILES: Array<{
name: string;
kind?: FileKind;
size: number;
text?: string;
entries?: { name: string; size: number }[];
}> = [
{ name: "Gate B at night.jpg", size: 1_840_000 },
{ name: "Dock plan.pdf", size: 240_000 },
{
name: "Notes.txt",
size: 320,
text: "Racks 1–7: aisle 7 uprights tagged red after the safety walk.",
},
{
name: "Invoices 2025.zip",
size: 12_600_000,
entries: [
{ name: "INV-2025-001.pdf", size: 84_000 },
{ name: "INV-2025-002.pdf", size: 91_000 },
],
},
{ name: "setup.bin", size: 4_200_000 },
];
export default function WithDetails() {
const [at, setAt] = useState(0);
const file = FILES[at]!;
return (
<div style={{ width: "100%" }}>
<FilePreview
{...file}
meta="Tom Garnier · Oct 2"
position={{ index: at + 1, total: FILES.length }}
{...(at > 0 ? { onPrevious: () => setAt(at - 1) } : {})}
{...(at < FILES.length - 1 ? { onNext: () => setAt(at + 1) } : {})}
onDownload={() => {}}
onClose={() => {}}
aside={
<FileDetails
name={file.name}
size={file.size}
owner="Tom Garnier"
location="My files › Photos"
modified="Oct 2, 2026 · 08:15"
access={{
people: ["Tom Garnier", "Léa Martin"],
summary: "Restricted to the people above",
}}
/>
}
/>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | The title; the kind comes from it. |
kind | FileKind | fileKindOf(name) | folder, pdf, image, sheet, doc, text, slides, video, audio, archive, code, other. |
size | number | — | In bytes. |
src / text / entries | string; string; { name, size? }[] | — | The address of a picture, PDF or video; the text of a page; an archive's files. |
children | ReactNode | — | Your own stage: a sheet, slides. |
onPrevious / onNext / position | () => void; { index, total } | — | The arrows in the header and on the keyboard. |
onDownload / onClose / actions | () => void; ReactNode | — | The header's buttons; Escape closes. |
meta | ReactNode | — | A line under the name. |
aside | ReactNode | — | A panel at the right: FileDetails. |
className | string | — | Extra classes. |