scrollfx
start here
Get started
  1. 1from
  2. 2bend · 0.3
  3. width · 160
  4. height · 96

Schedule of props

MarkPropTypeDefaultDescription
P1variantInkArrowVariant'curved'—
P2widthnumber160The box the arrow is drawn in, in px.
P3heightnumber96—
P4from[number, number][0.06, 0.3]Where the arrow starts, as a share of the box (0 to 1 across, 0 to 1 down).
P5to[number, number][0.92, 0.74]Where its head is, likewise.
P6bendnumber0.3How far a curved or looped arrow bends to one side, as a share of its length; negative bends it the other way.
P7headnumber12The length of the head's barbs, in px.
P8accentstring'#e0482a'The pen's colour: the accent, unless you pass `currentColor` for ink.
P9strokeWidthnumber1.6—
P10seednumber1—
P11triggerInkTrigger'scroll'`scroll`: drawn as it rises, done at mid-screen. `view`: played once as it comes into view.
P12durationnumber1100With `view`, how long the arrow takes, in ms.
P13classNamestring''—

Notes

  1. 1.
    A hand-drawn arrow pointing at something: nearly straight, curved, or looped, with a head made in one stroke.
  2. 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. 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.
  1. 4.
    Detail A, Curved. A curve bending to one side, from a note to what it is about.
  2. 5.
    Usage, as drawn:
    import { InkArrow } from '@/components/scrollfx/ink-arrow';
    
    const Note = ({ children }: { children: React.ReactNode }) => <span className="font-serif text-xl italic tracking-[-0.01em] text-muted-foreground">{children}</span>;
    
    const Button = ({ children }: { children: React.ReactNode }) => (
      <span className="inline-flex h-11 items-center rounded-full bg-foreground px-6 text-[15px] font-medium text-background">{children}</span>
    );
    
    export function CurvedExample() {
      return (
        <div className="flex items-end gap-2">
          <div className="pb-20"><Note>start here</Note></div>
          <InkArrow className="mb-2" />
          <Button>Get started</Button>
        </div>
      );
    }
    
View source · components/scrollfx/ink-arrow.tsx
'use client';

/**
 * ink-arrow — an arrow drawn by hand to point at something: nearly straight,
 * curved to one side, or with a loop thrown half way, ending in a head made
 * in one stroke. The pen goes at one speed, shaft first, then the head.
 *
 * 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. Place it with `className` (absolute, in a flex row,
 * beside a note); `from` and `to` set where it starts and ends in its box.
 *
 * The arrow is made in the browser and hidden from assistive tech: say in
 * text what it points at. Reduced motion shows it drawn.
 */

import { useEffect, useRef, useState } from 'react';
import 'svg-scroll-draw/no-flash.css';
import { inkArrow, type ArrowKind, type Stroke } from '@/lib/plotter';
import { useInk, type InkTrigger } from '@/lib/ink';

export type InkArrowVariant = ArrowKind;

export interface InkArrowProps {
  variant?: InkArrowVariant;
  /** The box the arrow is drawn in, in px. */
  width?: number;
  height?: number;
  /** Where the arrow starts, as a share of the box (0 to 1 across, 0 to 1 down). */
  from?: [number, number];
  /** Where its head is, likewise. */
  to?: [number, number];
  /** How far a curved or looped arrow bends to one side, as a share of its length; negative bends it the other way. */
  bend?: number;
  /** The length of the head's barbs, in px. */
  head?: number;
  /** The pen's colour: the accent, unless you pass `currentColor` for 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`, how long the arrow takes, in ms. */
  duration?: number;
  className?: string;
}

export function InkArrow({
  variant = 'curved',
  width = 160,
  height = 96,
  from = [0.06, 0.3],
  to = [0.92, 0.74],
  bend = 0.3,
  head = 12,
  accent = '#e0482a',
  strokeWidth = 1.6,
  seed = 1,
  trigger = 'scroll',
  duration = 1100,
  className = '',
}: InkArrowProps) {
  const ref = useRef<SVGSVGElement>(null);
  const [strokes, setStrokes] = useState<Stroke[] | null>(null);
  const [fx, fy] = from, [tx, ty] = to;
  useEffect(() => {
    setStrokes(inkArrow({ w: width, h: height, kind: variant, from: [fx, fy], to: [tx, ty], bend, seed, head }));
  }, [variant, width, height, fx, fy, tx, ty, bend, seed, head]);
  const n = strokes?.length ?? 0;
  // One piece after another: the pen keeps one speed down the shaft and round the head.
  useInk(ref, { paths: n, spread: Math.max(0, n - 1), trigger, duration, version: strokes });
  return (
    <svg
      ref={ref}
      key={strokes ? strokes.length + strokes[0]?.d : 'empty'}
      data-scroll-draw-pending=""
      data-ink={trigger}
      aria-hidden
      width={width}
      height={height}
      viewBox={`0 0 ${width} ${height}`}
      className={`pointer-events-none shrink-0 overflow-visible ${className}`}
      fill="none"
      stroke={accent}
      strokeWidth={strokeWidth}
      strokeLinecap="round"
      strokeLinejoin="round"
    >
      {strokes?.map((s, i) => <path key={i} d={s.d} />)}
    </svg>
  );
}

Parts list

ItemPart, as installed
1components/scrollfx/ink-arrow.tsxThe component
2lib/ink.tsThe pen hook the ink pieces share, and Hershey’s script
3lib/plotter.tsStroke geometry: hatching, sketched lines, scroll windows
4svg-scroll-draw ^2.29.0Dependency, from npm
ViewCurved
Pens1ink2vermilion
Installnpx shadcn@latest add
https://scrollfx-ui.vercel.app/r/ink-arrow.json
Title

Ink arrow

scrollfx · Ink
Dwg no.
ink-arrow
Sheet
14/14
Scale
1:1
Rev
2.29.0
Drawn by
svg-scroll-draw
Licence
MIT