How to make an SVG line draw itself
A line that draws in front of the viewer, good for logos, signatures and arrows.
Steps
- Set stroke-dasharray to the path length.
- Start with stroke-dashoffset at the same length.
- Animate the offset to zero.
The code
path{fill:none;stroke:#ff5e1a;stroke-width:4;stroke-dasharray:300;stroke-dashoffset:300;animation:draw 2.4s ease-in-out forwards}
@keyframes draw{to{stroke-dashoffset:0}}Want ready-made variations? The library has hundreds, each with standalone code.