Studio
For teams that ship weekly.
Unlimited projects, shared plates, and a seat for everyone who reviews.
- 1variant · rect
- 2accent · second pass
- 3children · any
Schedule of props
| Mark | Prop | Type | Default | Description |
|---|---|---|---|---|
| P1 | children* | ReactNode | — | — |
| P2 | variant | InkFrameVariant | 'rect' | — |
| P3 | color | string | 'currentColor' | The ink's colour. |
| P4 | accent | string | '#e0482a' | The accent pen's colour (the second pass, the inner frame). |
| P5 | strokeWidth | number | 1.1 | — |
| P6 | seed | number | 1 | — |
| P7 | trigger | InkTrigger | 'scroll' | `scroll`: drawn as it rises, done at mid-screen. `view`: played once as it comes into view. |
| P8 | duration | number | 1400 | With `view`, the drawing's length in ms. |
| P9 | className | string | '' | — |
* required
Notes
- 1.A border a pen draws round any children: rect or rounded (twice round, ink then accent), double, or crop marks at the corners.
- 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, Rect. The pen goes round twice, ink then accent, never quite on the same line.
- 5.Usage, as drawn:
import { InkFrame } from '@/components/scrollfx/ink-frame'; function Card({ eyebrow, title, body }: { eyebrow: string; title: string; body: string }) { return ( <> <p className="font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground">{eyebrow}</p> <h3 className="mt-4 font-serif text-3xl leading-tight tracking-[-0.02em]">{title}</h3> <p className="mt-3 text-pretty text-[15px] leading-relaxed text-muted-foreground">{body}</p> </> ); } export function RectExample() { return ( <InkFrame className="max-w-md p-8"> <Card eyebrow="Studio" title="For teams that ship weekly." body="Unlimited projects, shared plates, and a seat for everyone who reviews." /> </InkFrame> ); }
- 4.Detail B, Rounded. The same two passes with round corners, for softer cards.
- 5.Usage, as drawn:
import { InkFrame } from '@/components/scrollfx/ink-frame'; function Card({ eyebrow, title, body }: { eyebrow: string; title: string; body: string }) { return ( <> <p className="font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground">{eyebrow}</p> <h3 className="mt-4 font-serif text-3xl leading-tight tracking-[-0.02em]">{title}</h3> <p className="mt-3 text-pretty text-[15px] leading-relaxed text-muted-foreground">{body}</p> </> ); } export function RoundedExample() { return ( <InkFrame variant="rounded" seed={4} className="max-w-md p-8"> <Card eyebrow="Note" title="Seeded, so it never jumps." body="The same seed draws the same frame on every visit, and on the server and the client alike." /> </InkFrame> ); }
- 4.Detail C, Double. A finer frame in the accent pen just inside the first, as round a certificate.
- 5.Usage, as drawn:
import { InkFrame } from '@/components/scrollfx/ink-frame'; export function DoubleExample() { return ( <InkFrame variant="double" seed={7} className="max-w-md bg-card p-10 text-center"> <p className="font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground">Awarded to</p> <p className="mt-4 font-serif text-4xl italic tracking-[-0.02em]">Okkara Labs</p> <p className="mt-4 text-[15px] text-muted-foreground">for the clearest changelog of the year</p> </InkFrame> ); }
- 4.Detail D, Corner marks. Crop marks at the corners, as on a printer’s proof: for a figure, an image or a plate.
- 5.Usage, as drawn:
import { InkFrame } from '@/components/scrollfx/ink-frame'; export function CornerMarksExample() { return ( <figure className="max-w-md"> <InkFrame variant="corner-marks" className="p-3"> <div className="grid aspect-[4/3] place-items-center bg-card font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground">Your image here</div> </InkFrame> <figcaption className="mt-5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground">Fig. 1 — A plate, trimmed to the marks</figcaption> </figure> ); }
View source · components/scrollfx/ink-frame.tsx
'use client';
/**
* ink-frame — a border a pen draws round anything: a card, a figure, an
* image, a quote. `rect` and `rounded` go round twice, ink then accent, never
* quite on the same line; `double` draws a second, finer frame inside the
* first; `corner-marks` sets crop marks at the corners, as on a proof.
*
* 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 frame draws on the box's edge: give the box its
* own padding (and a `bg-card` if it should read as a sheet).
*
* What it frames is in the server HTML; the frame is made in the browser at
* the size it finds, and made again when that changes. Reduced motion shows
* it drawn.
*/
import { useRef, type ReactNode } from 'react';
import 'svg-scroll-draw/no-flash.css';
import { cropMarks, sketchRect, type Stroke } from '@/lib/plotter';
import { useInk, useSize, type InkTrigger } from '@/lib/ink';
export type InkFrameVariant = 'rect' | 'rounded' | 'double' | 'corner-marks';
export interface InkFrameProps {
children: ReactNode;
variant?: InkFrameVariant;
/** The ink's colour. */
color?: string;
/** The accent pen's colour (the second pass, the inner frame). */
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;
}
/** How far the drawing reaches past the box on each side, so strokes on its edge are not cut. */
const BLEED = 10;
type Placed = Stroke & { at: number };
function strokesFor(variant: InkFrameVariant, w: number, h: number, seed: number): Placed[] {
// Each frame is drawn in its own box, moved `at` px in from the drawing's corner.
const place = (s: Stroke[], at: number) => s.map((k) => ({ ...k, at }));
switch (variant) {
case 'rect':
return place(sketchRect({ w: w + 4, h: h + 4, seed, wobble: 1.3, r: 3 }), BLEED - 2);
case 'rounded':
return place(sketchRect({ w: w + 4, h: h + 4, seed, wobble: 1.3, r: 16 }), BLEED - 2);
case 'double':
return [
...place(sketchRect({ w: w + 4, h: h + 4, seed, wobble: 1.2, r: 3 }).slice(0, 1), BLEED - 2),
...place(sketchRect({ w: w - 10, h: h - 10, seed: seed + 5, wobble: 0.9, r: 2 }).slice(0, 1).map((k) => ({ ...k, pen: 1 as const })), BLEED + 5),
];
case 'corner-marks':
return place(cropMarks({ w: w + 2 * BLEED, h: h + 2 * BLEED, seed, len: Math.min(22, Math.max(10, Math.min(w, h) * 0.08)), inset: 2 }), 0);
}
}
export function InkFrame({
children,
variant = 'rect',
color = 'currentColor',
accent = '#e0482a',
strokeWidth = 1.1,
seed = 1,
trigger = 'scroll',
duration = 1400,
className = '',
}: InkFrameProps) {
const box = useRef<HTMLDivElement>(null);
const svg = useRef<SVGSVGElement>(null);
const size = useSize(box);
const strokes = size ? strokesFor(variant, size.w, size.h, seed) : null;
const n = strokes?.length ?? 0;
// The second pass follows the first; crop marks go down one corner after another.
useInk(svg, { paths: n, spread: n > 1 ? 0.5 : 0, trigger, duration, version: size && `${size.w}x${size.h}` });
return (
<div ref={box} className={`relative ${className}`}>
{children}
{size && strokes && (
<svg
ref={svg}
key={`${size.w}x${size.h}`}
data-scroll-draw-pending=""
data-ink={trigger}
aria-hidden
width={size.w + 2 * BLEED}
height={size.h + 2 * BLEED}
viewBox={`0 0 ${size.w + 2 * BLEED} ${size.h + 2 * BLEED}`}
className="pointer-events-none absolute overflow-visible"
style={{ left: -BLEED, top: -BLEED }}
fill="none"
stroke={color}
strokeWidth={strokeWidth}
strokeLinecap="round"
strokeLinejoin="round"
>
{strokes.map((s, i) => <path key={i} d={s.d} transform={s.at ? `translate(${s.at} ${s.at})` : undefined} stroke={s.pen ? accent : undefined} strokeWidth={s.pen && variant === 'double' ? strokeWidth * 0.8 : undefined} />)}
</svg>
)}
</div>
);
}
Parts list
| Item | Part, as installed |
|---|---|
| 1 | components/scrollfx/ink-frame.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 |
ViewRect
Pens1ink2vermilion
Install
npx shadcn@latest add
https://scrollfx-ui.vercel.app/r/ink-frame.jsonTitle
Ink frame
scrollfx · Ink- Dwg no.
- ink-frame
- Sheet
- 10/14
- Scale
- 1:1
- Rev
- 2.29.0
- Drawn by
- svg-scroll-draw
- Licence
- MIT