Components / Field Editor

Documents and fields

Field Editor

Place signature, text, date and checkbox fields on a PDF. The output is the agreement format's fields.

  • @signnative/ui
  • MIT
  • Client only · no backend

The examples use a synthetic PDF made in your browser. Nothing is uploaded or sent.

Theme
The CSS variables this sets
:root {
  --signing-accent: #3157e8;
  --sig-accent: #3157e8;
  --sig-accent-soft: color-mix(in oklab, #3157e8 14%, white);
  --sig-radius: 8px;
  --radius-control: 8px;
  --radius-panel: 12px;
  --font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
}

In the signer page kit, set the accent with accentProps(accent) on the element around the surface; it sets data-signing-accent and --signing-accent. The secure elements take the same values as a checked appearance object instead.

Two parties, controlled

Choose a party and a page, add fields, drag them. The JSON below is what onChange gives.

Arrow keys move the field, Shift with arrow keys changes its size, Delete removes it.

Loading document…

Fields (1)

{
 "fields": [
  {
   "id": "client-signature-1",
   "type": "signature",
   "party": "client",
   "page": 2,
   "rect": [
    0.1,
    0.62,
    0.35,
    0.07
   ]
  }
 ]
}

One party, two field types, no snapping

Arrow keys move the field, Shift with arrow keys changes its size, Delete removes it.

Loading document…

Fields (0)

No fields yet. Choose a party and a page, then add a field.

Installation

npx shadcn@latest add <site>/r/field-editor.json

Not published yet

Not published yet. The registry item exists in packages/ui/registry.json but is not served yet.

API

className and children are left out: every component that takes them passes them on.

FieldEditor

NameTypeDefaultDescription
partiesEditorParty[]The parties (roles) fields can belong to. At least one.
fieldsEditorField[]Controlled fields. Leave it out to let the editor keep its own.
defaultFieldsEditorField[]Uncontrolled start value, read once.
onChange(fields: EditorField[]) => voidEvery field after each change, in the shape of an agreement file's fields.
typesreadonly EditorFieldType[]all fourField types that can be added.
gridnumber0.005Fields snap to this grid, a fraction of the page. 0 turns snapping off.
dataArrayBuffer | Uint8Array | nullThe PDF, as for PdfViewer.
pdfjsPdfjsLib | (() => Promise<PdfjsLib>)pdf.js, as for PdfViewer.
workerSrcstringAs for PdfViewer.
assetsUrlstringAs for PdfViewer.
pageWidthnumberAs for PdfViewer.
maxWidthnumber820As for PdfViewer.
textLayerbooleantrueAs for PdfViewer.
onPagesMeasured(sizes: PdfPageSize[]) => voidOnce, with every page's size in PDF points.
labelsPartial<FieldEditorLabels>EnglishEvery text, for translation.

Accessibility

  • Each field on the page has a name with its type, party, page and position.
  • Arrow keys move a field, Shift with arrow keys changes its size, Delete removes it. Changes are announced.