A definition list of a document's PDF properties, sourced straight from the engine.
About#
<PdfDocumentInfo /> lists a document's PDF properties — file name, title,
author, subject, keywords, dates, creator, producer, and page count — read
straight from the engine's getMetadata() and the loaded document. It's the
shared body of both the document properties dialog and the
library browser block's information sidebar, so the
two never drift apart.
- Follows the viewer — with no props it describes the ambient viewer
document (the focused view's active document), so it tracks whatever the
viewer is showing. Pass
documentIdto pin it to a specific document. - Grouped, not listed — properties sit in four ruled sections (File,
Description, Origin, Format) with a fixed label column, laid out
like
<PdfAnnotationInspector />. - Honest fallbacks — file size, PDF version, and Fast Web View aren't
tracked once a document is open, so those render
N/A. Empty metadata fields render an em dash.
The render and document-manager plugins that source this all ship inside
<PdfViewer> already, so the panel needs no extra plugin registration.
Installation#
pnpm dlx shadcn@latest add @pdfviewcn/document-info
Usage#
Place <PdfDocumentInfo> inside a <PdfViewer>. With no props it describes
the document the viewer is showing.
<PdfViewer documents={[{ url: "/sample.pdf" }]} className="h-[720px]">
<div className="flex h-full min-h-0">
<PdfViewerContent />
<aside className="w-80 border-l p-4">
<PdfDocumentInfo />
</aside>
</div>
</PdfViewer>The component brings no horizontal padding of its own, so the section rules run
to the edges of whatever it's dropped into. Both of its own hosts — the
properties dialog and the library browser's sidebar — pad already; a bare panel
should pass px-4.
Examples#
In a dialog#
<PdfDocumentPropertiesDialog />
is this panel in a dialog, with a trigger already wired. Reach for it before
building the same thing:
<PdfToolbar>
<PdfPageNavigation />
<div className="ml-auto flex items-center gap-1">
<PdfDocumentPropertiesDialog />
</div>
</PdfToolbar>Describing a document other than the open one#
documentId pins the panel to one document, which is how a browsing layout
inspects a card without opening it. The library browser
does exactly this — a grid of documents beside a sidebar describing the selected
one:
<aside className="w-80 border-l px-4 py-2">
<PdfDocumentInfo documentId={selectedId} />
</aside>Every open document carries plugin state whether or not it's on screen, so the panel resolves without the document being visible anywhere.
Accessibility#
Each property is a <dt>/<dd> pair inside a <dl>, one <dl> per section, so
a screen reader reads a label with its value rather than a row of loose text.
Sections are <section> elements with their own heading, making the four groups
navigable as landmarks.
Values truncate visually but carry their full text on title, so nothing is lost
to the fixed label column. While the metadata resolves, the panel renders a
skeleton shaped like the sections it stands in for — the layout doesn't shift
when the values arrive.
API Reference#
PdfDocumentInfo#
A <div> carrying data-slot="pdf-document-info". Accepts every prop a <div>
takes, plus:
| Prop | Type | Default | Description |
|---|---|---|---|
documentId | string | null | ambient document | The document to describe. Defaults to the focused view's active document; pass an id to pin it to a specific one. |
Styling the sections#
| Slot | Element | Description |
|---|---|---|
pdf-document-info | div | The root. Sets the 12px panel tier every row inherits. |
pdf-document-info-list | div | The four sections, once the metadata has resolved. |
pdf-document-info-section | section | One labelled group. A <dl> per section, ruled off from the next. |
pdf-document-info-skeleton | div | The loading state, shaped like the sections it stands in for. |
Each row is a <dt>/<dd> pair on one line. The label column is fixed to the
panel's longest label, so values line up across all four sections rather than
stepping in and out.