Signer page kit
Placed Field
A field the sender places on a page: drag to move, drag the corner to resize, or use the keyboard.
- In the signer page, not yet in the package
- AGPL-3.0-only
- Client only · no backend
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.
Move, resize, remove
Drag it, drag the corner, or Tab to it and use the keys.
Drag to move. Arrow keys move it by half a percent of the page, Shift and arrow keys resize it, Delete removes it. Signature
x 0.100 · y 0.400 · w 0.400 · h 0.200
tsx
import { useState } from "react";
import { PlacedField, type Box } from "@/components/signing";
export function Example() {
const [box, setBox] = useState<Box>({ x: 0.1, y: 0.4, width: 0.4, height: 0.2 });
const [removed, setRemoved] = useState(false);
return (
<div style={{ position: "relative", width: 420, height: 240 }}>
{!removed && (
<PlacedField box={box} onChange={setBox} onRemove={() => setRemoved(true)} label="Signature" selected>
Signature
</PlacedField>
)}
</div>
);
}
Several fields
Drag to move. Arrow keys move it by half a percent of the page, Shift and arrow keys resize it, Delete removes it.Signature
Drag to move. Arrow keys move it by half a percent of the page, Shift and arrow keys resize it, Delete removes it.Date
Drag to move. Arrow keys move it by half a percent of the page, Shift and arrow keys resize it, Delete removes it.Text
Tab to a field, then use the arrow keys. Shift and arrows resize, Delete removes.
tsx
import { useState } from "react";
import { PlacedField, type Box } from "@/components/signing";
type Field = { id: string; label: string; box: Box };
export function Example() {
const [fields, setFields] = useState<Field[]>([
{ id: "sig", label: "Signature", box: { x: 0.08, y: 0.55, width: 0.42, height: 0.16 } },
{ id: "date", label: "Date", box: { x: 0.6, y: 0.6, width: 0.28, height: 0.1 } },
]);
return (
<div style={{ position: "relative", width: 420, height: 240 }}>
{fields.map((f) => (
<PlacedField
key={f.id}
id={f.id}
box={f.box}
label={f.label}
onChange={(b) => setFields((list) => list.map((x) => (x.id === f.id ? { ...x, box: b } : x)))}
onRemove={() => setFields((list) => list.filter((x) => x.id !== f.id))}
>
{f.label}
</PlacedField>
))}
</div>
);
}
Installation
npx shadcn@latest add …
Not published yet
Not in the registry (packages/ui/registry.json) yet.
Props
className and children are left out: every component that takes them passes them on.
PlacedField
| Name | Type | Default | Description |
|---|---|---|---|
| box | Box | Position and size on the page, each 0 to 1. | |
| onChange | (b: Box) => void | Called while it is dragged, resized or moved with keys. | |
| onRemove | () => void | The × button and Delete. | |
| label | string | What the field is, for screen readers. | |
| selected | boolean | false | Show the handles without focus, e.g. right after placing. |
| onSelect | () => void | Called when the field gets focus. | |
| minWidth | number | 0.06 | Smallest width, as a share of the page. |
| minHeight | number | 0.02 | Smallest height, as a share of the page. |
| id | string | Set as data-field-id, to focus a field just placed. |
Accessibility
- Arrow keys move the field, Shift with an arrow resizes it, Delete removes it.
- The label names the field for screen readers, with the keys in its description.