Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <svg xmlns="" 
		 viewBox="0 0 1200 300"
  <path class="path" d="M1130,233.5c0,0-217.7,159.8-294.4,0S433.7,331,357,201.2C264,49.3,188.6,95.5,158.1,114.9s-82.5,84.7,0,206.1"/>

<div class="buttons-block">
  <button class='left'>Animate from left</button>
  <button class='right'>Animate from right</button>



                body {
  background-color: rgba(100,100,100,.3); 
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-content: center;
  height: 90vh;

svg {
  width: 100%;
  height: 400px;

.path {
  fill: none;
	stroke: red;
	stroke-width: 4;
  stroke-linecap: round;
  stroke-opacity: 0;
  transition: stroke-opacity .5s ease-in;
.buttons-block {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  button {
    padding: 20px;
    border: none;
    outline: none;
    text-transform: uppercase;
    background-color: lightgreen;
    font-family: sans-serif;
    font-size: 20px;
    box-shadow: inset 0px -20px 39px -18px rgba(0,0,0,0.2);
    transition: all .3s ease-in-out;
    &:hover {
      box-shadow: inset 0px 20px 39px -18px rgba(0,0,0,0.2);



                var path = document.getElementsByClassName('path').item(0),
    leftBtn = document.getElementsByClassName('left').item(0),
    rightBtn = document.getElementsByClassName('right').item(0),
    clickFlag = false;

var dashDrawInterval;

// Starting and pausing animation

// From right
rightBtn.addEventListener("click", function (){
  clickFlag = !clickFlag;
  clickFlag ? animateDashedPath(path, 10, 3000, 'right') : clearInterval(dashDrawInterval);

// From left
leftBtn.addEventListener("click", function() {
  clickFlag = !clickFlag;
  clickFlag ? animateDashedPath(path, 10, 3000, 'left') : clearInterval(dashDrawInterval);

// Animates the given path element with given dash length, animation duration and direction 
function animateDashedPath (path, dashLength, animationDuration, animationDirection) {
  var pathLength = path.getTotalLength(),
      numberOfSteps = Math.round(pathLength / (dashLength*2) + 1),
      stepDuration = animationDuration / numberOfSteps,
      doublePath = path.getTotalLength()*2;

  // Build the dash array so we don't have to do it manually
  var dashArray = [];
  for (var i = numberOfSteps; i > 0; i--) {

  // Animation start conditions
  path.setAttribute("stroke-dasharray", dashArray.join(" "));
  path.setAttribute("stroke-dashoffset", -pathLength);
  // Animating dash until it is full 
  // From right to left
  function dashAnimateRight () { = 1;
    pathLength += dashLength*2;
    path.setAttribute("stroke-dashoffset", -pathLength);
    if (pathLength > doublePath ) {
  // From left to right
  function  dashAnimateLeft() { = 1;
    pathLength -= dashLength*2;
    path.setAttribute("stroke-dashoffset", -pathLength);
    if (pathLength <= 0) {
  if (animationDirection === 'right' ) {
    dashDrawInterval = setInterval(dashAnimateRight, stepDuration);  
  if (animationDirection === 'left' ) {
    dashDrawInterval = setInterval(dashAnimateLeft, stepDuration);