Approved — Quality checked · Batch 07 · 2026 ·
- 1rim · round the band
- 2children · the word
- 3rotate · −8°
- size · 148
Schedule of props
| Mark | Prop | Type | Default | Description |
|---|---|---|---|---|
| P1 | children* | ReactNode | — | The words in the middle: keep them short. |
| P2 | variant | InkStampVariant | 'circle' | — |
| P3 | rim | string | — | A line of text round the rim, for `circle` and `seal`. It is spaced to go once round. |
| P4 | size | number | 148 | The width and height of `circle` and `seal`, in px. |
| P5 | rotate | number | -8 | How far the stamp is turned, in degrees. |
| P6 | accent | string | '#e0482a' | The stamp's ink. |
| P7 | strokeWidth | number | 1.4 | — |
| P8 | seed | number | — | — |
| P9 | trigger | InkTrigger | 'scroll' | `scroll`: drawn as it rises, done at mid-screen. `view`: played once as it comes into view. |
| P10 | duration | number | 1400 | With `view`, the drawing's length in ms. |
| P11 | className | string | '' | — |
* required
Notes
- 1.A short word or two inside a plotted stamp: a circle with text round its rim, a rectangle ruled twice, or a scalloped seal, set a little askew.
- 2.The words and content it marks stay in the server HTML. The marks are measured to them in the browser, and made again when the layout changes.
- 3.Tied to the scroll by default: the last stroke lands as the drawing reaches the middle of the screen. With
trigger="view"it plays once as it comes into view instead. Reduced motion shows it drawn.
- 4.Detail A, Circle. Two rings round the rim and one inside, with a line of text set round the band between them.
- 5.Usage, as drawn:
import { InkStamp } from '@/components/scrollfx/ink-stamp'; export function CircleExample() { return ( <InkStamp rim="Quality checked · Batch 07 · 2026 ·">Approved</InkStamp> ); }
- 4.Detail B, Rectangle. Ruled twice round the words, then once more, finer, inside; it sizes to them.
- 5.Usage, as drawn:
import { InkStamp } from '@/components/scrollfx/ink-stamp'; export function RectangleExample() { return ( <div className="flex flex-wrap items-center gap-10"> <InkStamp variant="rectangle">Draft</InkStamp> <InkStamp variant="rectangle" rotate={4} seed={8}>Paid in full</InkStamp> </div> ); }
- 4.Detail C, Seal. A scalloped edge, a ring and a dotted ring inside, for a guarantee or a first edition.
- 5.Usage, as drawn:
import { InkStamp } from '@/components/scrollfx/ink-stamp'; export function SealExample() { return ( <InkStamp variant="seal" rim="First edition · Plotted by hand ·" rotate={6} size={164}>Est. 2026</InkStamp> ); }
View source · components/scrollfx/ink-stamp.tsx
'use client';
/**
* ink-stamp — a short word or two set inside a stamp a pen plots round it: a
* round stamp with a line of text running round its rim, a rectangle ruled
* twice, or a seal with a scalloped edge. Set a little askew, as a stamp
* lands.
*
* Built on svg-scroll-draw (MIT): https://github.com/DhruvilChauahan0210/scrollfx
* Needs: react, svg-scroll-draw, lib/plotter and lib/ink (installed with it).
* Styling: Tailwind CSS. The whole stamp is in the one `accent` colour, as a
* stamp is in one ink.
*
* The words, and the rim's text on its circle, are in the server HTML; the
* rings and the frame are made in the browser. Reduced motion shows them
* drawn.
*/
import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react';
import 'svg-scroll-draw/no-flash.css';
import { seedOf, sketchRect, stampRings, type Stroke } from '@/lib/plotter';
import { useInk, useSize, type InkTrigger } from '@/lib/ink';
export type InkStampVariant = 'circle' | 'rectangle' | 'seal';
export interface InkStampProps {
/** The words in the middle: keep them short. */
children: ReactNode;
variant?: InkStampVariant;
/** A line of text round the rim, for `circle` and `seal`. It is spaced to go once round. */
rim?: string;
/** The width and height of `circle` and `seal`, in px. */
size?: number;
/** How far the stamp is turned, in degrees. */
rotate?: number;
/** The stamp's ink. */
accent?: string;
strokeWidth?: number;
seed?: number;
/** `scroll`: drawn as it rises, done at mid-screen. `view`: played once as it comes into view. */
trigger?: InkTrigger;
/** With `view`, the drawing's length in ms. */
duration?: number;
className?: string;
}
function Strokes({ strokes, w, h, view, accent, strokeWidth, trigger, duration, spread }: { strokes: Stroke[]; w: number; h: number; view?: string; accent: string; strokeWidth: number; trigger: InkTrigger; duration: number; spread: number }) {
const ref = useRef<SVGSVGElement>(null);
useInk(ref, { paths: strokes.length, spread, trigger, duration, version: strokes });
return (
<svg ref={ref} data-scroll-draw-pending="" data-ink={trigger} aria-hidden width={w} height={h} viewBox={view ?? `0 0 ${w} ${h}`} className="pointer-events-none absolute inset-0 overflow-visible" fill="none" stroke={accent} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round">
{strokes.map((s, i) => <path key={i} d={s.d} />)}
</svg>
);
}
export function InkStamp({
children,
variant = 'circle',
rim,
size = 148,
rotate = -8,
accent = '#e0482a',
strokeWidth = 1.4,
seed,
trigger = 'scroll',
duration = 1400,
className = '',
}: InkStampProps) {
const id = useId();
const s = seed ?? seedOf(`${variant}${rim ?? ''}`);
const pen = { accent, trigger, duration };
const box = useRef<HTMLSpanElement>(null);
const measured = useSize(box);
const [rings, setRings] = useState<Stroke[] | null>(null);
useEffect(() => {
if (variant !== 'rectangle') setRings(stampRings({ size: 100, seed: s, kind: variant }));
}, [variant, s]);
// Ruled twice round the edge, then once more, finer, inside.
const frame = useMemo(
() => (variant === 'rectangle' && measured ? [...sketchRect({ w: measured.w, h: measured.h, seed: s, wobble: 1, r: 3 }), shift(sketchRect({ w: measured.w - 10, h: measured.h - 10, seed: s + 3, wobble: 0.7, r: 2 })[0], 5)] : null),
[variant, measured, s],
);
if (variant === 'rectangle') {
const strokes = frame;
return (
<span ref={box} className={`relative inline-flex items-center justify-center px-7 py-4 ${className}`} style={{ rotate: `${rotate}deg`, color: accent }}>
<span className="font-mono text-[15px] font-semibold uppercase leading-none tracking-[0.28em]">{children}</span>
{measured && strokes && <RectFrame key={`${measured.w}x${measured.h}`} strokes={strokes} w={measured.w} h={measured.h} {...pen} strokeWidth={strokeWidth} />}
</span>
);
}
// The rim's text sits in the band between the outer rings and the inner one.
const r = size * (variant === 'seal' ? 0.36 : 0.38);
const rimFont = Math.max(7, size * (variant === 'seal' ? 0.056 : 0.066));
// The words fit inside the inner ring: a monospaced letter here is about 0.8 em wide with its tracking.
const longest = typeof children === 'string' ? Math.max(...children.split(/\s+/).map((w) => w.length)) : 6;
const wordFont = Math.max(9, Math.min(size * 0.1, (size * 0.48) / (longest * 0.8)));
const circle = `M${size / 2 - r} ${size / 2}a${r} ${r} 0 1 1 ${r * 2} 0a${r} ${r} 0 1 1 ${-r * 2} 0`;
return (
<span className={`relative inline-grid shrink-0 place-items-center ${className}`} style={{ width: size, height: size, rotate: `${rotate}deg`, color: accent }}>
{rim && (
<svg aria-hidden width={size} height={size} viewBox={`0 0 ${size} ${size}`} className="absolute inset-0 overflow-visible">
<defs>
<path id={`${id}-rim`} d={circle} />
</defs>
<text fill="currentColor" className="font-mono uppercase" style={{ fontSize: rimFont, letterSpacing: '0.12em' }} dominantBaseline="central">
<textPath href={`#${id}-rim`} textLength={Math.PI * 2 * r - size * 0.04} lengthAdjust="spacing">{rim}</textPath>
</text>
</svg>
)}
<span className="max-w-[60%] text-center font-mono font-semibold uppercase leading-tight tracking-[0.2em]" style={{ fontSize: wordFont }}>
{children}
{rim && <span className="sr-only"> — {rim}</span>}
</span>
{rings && <Strokes strokes={rings} w={size} h={size} view="0 0 100 100" spread={0.6} {...pen} strokeWidth={strokeWidth * (100 / size)} />}
</span>
);
}
/** A stroke moved `by` px right and down (its numbers are x y pairs). */
const shift = (k: Stroke, by: number): Stroke => ({ ...k, d: k.d.replace(/(-?[\d.]+) (-?[\d.]+)/g, (_, x, y) => `${(+x + by).toFixed(1)} ${(+y + by).toFixed(1)}`) });
function RectFrame(props: { strokes: Stroke[]; w: number; h: number; accent: string; strokeWidth: number; trigger: InkTrigger; duration: number }) {
return <Strokes {...props} spread={0.6} />;
}
Parts list
| Item | Part, as installed |
|---|---|
| 1 | components/scrollfx/ink-stamp.tsxThe component |
| 2 | lib/ink.tsThe pen hook the ink pieces share, and Hershey’s script |
| 3 | lib/plotter.tsStroke geometry: hatching, sketched lines, scroll windows |
| 4 | svg-scroll-draw ^2.29.0Dependency, from npm |
ViewCircle
Pens1ink2vermilion
Install
npx shadcn@latest add
https://scrollfx-ui.vercel.app/r/ink-stamp.jsonTitle
Ink stamp
scrollfx · Ink- Dwg no.
- ink-stamp
- Sheet
- 12/14
- Scale
- 1:1
- Rev
- 2.29.0
- Drawn by
- svg-scroll-draw
- Licence
- MIT