Skip to content
GitHub (opens in a new tab)

DocumentPreview

One page of a document with the values an agent read from it highlighted.

stableOrganismcontracts/documentpreview.json

Preview

DocumentPreview

One page with the values an agent read from it highlighted. Not InvoiceDocument. Not RedactionPreview.

Master

Select a highlight to make it active. The issue is the full warning tone, low confidence a softer dashed tint, and each name says so.

Document preview

Globex-INV-7731.pdfPage 1 of 1100%

Usage

DocumentPreview is the page half of a review: pass an image of the page (src) or draw it as children, and give each extracted value a box in percent. Link it to your fields with activeId and onRegionSelect, so focusing a field lights its value and picking a value focuses its field. ReviewQueueScreen uses it this way, with this same sample invoice.

Do's

  • a person checks values an agent extracted from an invoice, receipt, contract or form against the page itself
  • link a field in a form to where its value sits on the page, both ways
  • show which values the agent was unsure of, on the page

Don'ts

  • an invoice you issue, laid out as a document — InvoiceDocument
  • exactly what text leaves the product, with values masked — RedactionPreview
  • a list of uploaded files — FileUpload
<DocumentPreview
  fileName="INV-7731.pdf"
  src={pageImage}
  alt="Invoice INV-7731, page 1"
  regions={regions}          // { id, label, box: { x, y, w, h }, tone?: "low" | "issue" }
  activeId={activeField}
  onRegionSelect={focusField}
  onDownload={download}
/>

One page of a document with the values an agent read from it highlighted: a toolbar (file name, page of pages, zoom, download) over a scrollable page, and a button per highlighted value. The active highlight, linked to the field being edited beside it, gets a focus ring and aria-pressed. Not a PDF engine: pass an image of the page or draw the page yourself.

When to use

  • a person checks values an agent extracted from an invoice, receipt, contract or form against the page itself
  • link a field in a form to where its value sits on the page, both ways
  • show which values the agent was unsure of, on the page

When not to use

  • an invoice you issue, laid out as a document — InvoiceDocument
  • exactly what text leaves the product, with values masked — RedactionPreview
  • a list of uploaded files — FileUpload

What an agent reads

import { DocumentPreview } from "agentic-ds-kit";
must
  • section aria-labelledby a visually hidden h2 (title)
  • the page is a focusable region named "<fileName>, page <n> of <count>" so it scrolls with the keyboard
  • every highlight is a native button named by its label, with aria-pressed true on the active one
  • low and issue are never colour alone: low is dashed, issue is a thicker solid border, and the label says which
  • Zoom out, Zoom in, Previous page, Next page and Download are IconButtons with names; the zoom percent is a polite live output
  • an image page has alt text (alt, or the file name); a drawn page that repeats the fields beside it can be aria-hidden
  • loading sets aria-busy and the Skeleton says Loading document once
  • no motion of its own
defaults
  • page 1
  • pageCount 1
  • defaultZoom 100
  • loading false
  • title Document preview
stops if
  • Do not draw local highlight boxes over a page; use DocumentPreview regions
  • Do not mark low confidence or an issue by colour alone
  • Do not put a solid primary Button in the toolbar
  • Do not use raw hex

From contracts/documentpreview.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
fileNamestringYes—In the toolbar (ellipsis when long, full name in the title), in Download's name ("Download INV-20418.pdf") and in the page region's name.
pagenumberNo11-based page shown. "Page 1 of 1" in the toolbar.
pageCountnumberNo1Previous page and Next page IconButtons show when it is more than 1.
onPageChangefunctionNo—(page) => void. Previous page and Next page.
zoomnumberNo—Controlled zoom in percent, 50 to 200 in steps of 25. Uncontrolled when left out.
defaultZoomnumberNo100Uncontrolled starting zoom.
onZoomChangefunctionNo—(zoom) => void. Zoom out and Zoom in (ghost IconButtons); the percent between them is a live output.
onDownloadfunctionNo—() => void. Shows a Download IconButton at the end of the toolbar.
srcstringNo—An image of the page, contained in the sheet. Leave it out and pass the page as children.
altstringNo—With src. Defaults to fileName.
childrenslotNo—The page when there is no src: content laid out in percent of the sheet (position absolute inside it) so the regions line up at every zoom.
regionsarrayNo—Boxes in percent of the page (0 to 100, top-left origin). Only the current page's regions show. Each is a button named by label, so say what it is and how sure the agent is ("Show PO number in fields, issue: PO-7782 not found, 61% · Low confidence"). default is neutral (a thin strong line, a faint tint); low is a soft warning tint with a dashed border; issue is the full warning tone, solid and medium, for the value with a problem to fix. Tone is never the only signal: the label says low or issue too.
activeIdstringNo—The region linked to the active field: the strong focus outline and ring over its tone, aria-pressed. null or left out for none.
onRegionSelectfunctionNo—(id) => void. A region was clicked or pressed. Move focus to its field from here.
loadingbooleanNofalseThe toolbar stays; the sheet is a Skeleton that says Loading document; the section is aria-busy.
titlestringNoDocument previewNames the section: a visually hidden h2.
  • Component
    →

    InvoiceDocument

    A document view for an invoice or a credit note, not a PDF engine: header with status and actions, bill-to and dates, line items, totals and one line about payment.

  • Component
    →

    RedactionPreview

    Shows exactly what is about to leave the product for a model or outside tool, with sensitive values masked by type and a mask rule per type, before it is sent.

  • Component
    →

    FileUpload

    Choose files Button in a dashed drop zone (or a compact Button-only row) plus a list of file rows with progress, done, and error states.

  • Screen
    →

    Review queue

    Check what an agent read from a document before it posts.