SVG Curved TOC
Interactive Table of Contents
Click any item — or wait for auto-cycle
Cubic Bezier Connector
C 8 56 24 4 24 60Thumb Animation Method
clip-path
Only clip-path is animated — no layout recalc
offset-path / offset-distance
distance: 30% — element follows the path
Techniques from the article
- 1.Cubic Bezier curves — the SVG
Ccommand creates smooth S-curves between TOC items at different indent depths using control points offset by ±4px. - 2.clip-path animation — instead of
mask-image+transform, useclip-path: inset()to mask the highlighted SVG. Only the clip rect is transitioned, avoiding costly layout recalculation. - 3.Thumb box positioning — a small circle at the thumb edge. Keeping it on the curved path requires solving the Bezier polynomial or using
getPointAtLength()iteratively. - 4.offset-path — CSS property that pins an element to an SVG path using
offset-distance, but only accepts path distance, not y-position.
Based on Some Nice Things with SVG (Part 2) by @fuma_nama