Signer page kit
Kit helpers
The functions and hooks the kit exports: theming, contrast, layout and scrolling.
- 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.
Contrast and readable accents
contrastOnWhite = 2.14 · readableAccent = #4f71a2 (4.98)
tsx
import { accentProps, contrastOnWhite, readableAccent } from "@/components/signing";
export function Example({ hex = "#7fb3ff" }: { hex?: string }) {
return (
<div {...accentProps(hex)}>
<p>
{contrastOnWhite(hex).toFixed(2)} becomes {contrastOnWhite(readableAccent(hex)).toFixed(2)}
</p>
<button className="btn-primary">Sign document</button>
</div>
);
}
useCompactLayout
useCompactLayout(): false (1024 px or wider: a centred dialog)
tsx
import { useCompactLayout } from "@/components/signing";
export function Example() {
return <p>{useCompactLayout() ? "Phone layout" : "Wide layout"}</p>;
}
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.
Functions and hooks
| Name | Type | Default | Description |
|---|---|---|---|
| accentProps | (accent?: string | null) => props | Theme a signing surface. Light custom colours are darkened to 4.5:1. | |
| readableAccent | (hex: string) => string | The colour, or the same hue darkened until white text on it reaches 4.5:1. | |
| contrastOnWhite | (hex: string) => number | WCAG contrast of white text on the colour. | |
| signatureLineFor | (padHeight: number) => { height, below } | SignatureLine props that match a SignaturePad, so a drawing shows 1:1. | |
| initials | (name: string) => string | Up to two initials, for Avatar. | |
| scrollToField | (id: string) => void | Scroll a field into view and focus its control. | |
| useCompactLayout | (query?: string) => boolean | True below 1024 px (or for the media query given). | |
| useTargetDirection | (id: string | null) => "up" | "down" | null | Where an element is relative to the screen; null while it is visible. |