components / pencil-rule

pencil-rule.

a rule that draws itself with a pencil riding the leading edge. the stroke is a scaled element rather than an animated width, so it composites and never causes layout; the pencil shares the stroke's timing function, which is what keeps the nib pinned to the end of the line. draws on scroll-into-view by default. under reduced motion the finished rule renders immediately and the pencil never appears.

odd jobs, done properly.

the rule draws left to right and the pencil leaves once it lands.

installation
bunx @justin06lee/chrome@latest add pencil-rule
props
nametypedefaultdescription
durationnumber1.2seconds to cross the full width.
delaynumber0
trigger'in-view' | 'mount''in-view'
repeatbooleanfalseredraw every time it re-enters the viewport.
thicknessnumber1line thickness in px.
colorstring'rgba(255,255,255,0.35)'
pencilColorstring'rgba(255,255,255,0.75)'
showPencilbooleantruefalse draws the line alone.
classNamestring-