Skip to content

components/rough-drawing

RoughMark = "box" | "underline" | "circle" | "highlight" | "bubble" | "line"

A hand-drawn mark around, under or behind an element.


RoughTone = "ink" | "coral"

Theme ink (currentColor by default) or the theme’s coral accent.


RoughSpec = Readonly<{ mark: RoughMark; seed: number; weight: number; roughness: number; fill: "none" | "solid" | "hachure"; tail: "left" | "right" | "none"; points: readonly readonly [number, number][]; }>

Parsed data-rough-* settings for one element.

parseRoughPoints(value): readonly readonly [number, number][]

Read 0,100 40,20 100,0 as percent points, dropping malformed pairs.

string | undefined

readonly readonly [number, number][]


readRoughSpec(element): Readonly<{ mark: RoughMark; seed: number; weight: number; roughness: number; fill: "none" | "solid" | "hachure"; tail: "none" | "left" | "right"; points: readonly readonly [number, number][]; }> | null

Parse an element’s data-caps-rough and data-rough-* attributes.

HTMLElement

Readonly<{ mark: RoughMark; seed: number; weight: number; roughness: number; fill: "none" | "solid" | "hachure"; tail: "none" | "left" | "right"; points: readonly readonly [number, number][]; }> | null


drawRough(root?): () => void

Draw every [data-caps-rough] element inside root (and root itself), loading Rough.js on first use, and redraw each one when its size changes. Returns a function that stops watching sizes. If Rough.js cannot load, the CSS fallback stays.

ParentNode = document

() => void