Skip to main content
Animates the stroke of an SVG element, like drawing a line. in transitions begin with the path invisible and draw the path to the screen over time. out transitions start in a visible state and gradually erase the path. The draw transition only works with elements that have a getTotalLength method, such as <path> and <polyline>.

Usage

Parameters

delay
number
default:"0"
Milliseconds before starting the transition
duration
number | function
Duration of the transition in milliseconds, or a function that takes the path length and returns a duration. If neither duration nor speed is specified, defaults to 800ms
speed
number
The speed of the animation in pixels per millisecond. If specified, the duration will be calculated as length / speed. Cannot be used together with duration
easing
function
default:"cubicInOut"
An easing function that controls the animation curve

Example with parameters

Notes

The animation uses the SVG stroke-dasharray and stroke-dashoffset properties to create the drawing effect. If the element has stroke-linecap set to anything other than butt, the stroke width is added to the path length to ensure smooth animation.