Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                <div style="min-height: 150vh">Scroll down to start animation ↓</div>
<svg width="543" height="225" viewBox="0 0 543 225" fill="none"
  xmlns="http://www.w3.org/2000/svg">
  <path d="M35.5 20C216.281 20 352.411 182 512.5 182" stroke="url(#my-svg-paint0_linear)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="500" stroke-dashoffset="500">
    <animate id="mysvgline" attributeType="xml" attributeName="stroke-dashoffset" from="500" to="0" dur="800ms" begin="indefinite" repeatCount="1" fill="freeze" />
  </path>
  <circle cx="34" cy="20.5" r="7.5" fill="#FFB916">
    <animate attributeType="xml" attributeName="cx" from="0" to="0" dur="10ms" begin="mysvgline.begin" repeatCount="1" fill="freeze" />
    <animate attributeType="xml" attributeName="cy" from="0" to="0" dur="10ms" begin="mysvgline.begin" repeatCount="1" fill="freeze" />
    <animate attributeType="xml" attributeName="fill" from="#FFB916" to="#5CEBDF" dur="800ms" begin="mysvgline.begin" repeatCount="1" fill="freeze" />
    <animateMotion begin="mysvgline.begin" dur="800ms" repeatCount="1" path="M35.5 20C216.281 20 352.411 182 512.5 182" fill="freeze" />
  </circle>
  <g filter="url(#my-svg-filter0_d)" opacity="0">
    <animate attributeType="xml" attributeName="opacity" from="0" to="1" dur="200ms" begin="1400ms" repeatCount="1" fill="freeze" />
  </g>
  <g>
    <rect x="0" y="40" width="66" height="24" rx="12" fill="#FFB916">
      <animate attributeType="xml" attributeName="fill" from="#FFB916" to="#5CEBDF" dur="800ms" begin="mysvgline.begin" repeatCount="1" fill="freeze" />
    </rect>
    <path d="M34 32L38.7631 40.25H29.2369L34 32Z" fill="#FFB916">
      <animate attributeType="xml" attributeName="fill" from="#FFB916" to="#5CEBDF" dur="800ms" begin="mysvgline.begin" repeatCount="1" fill="freeze" />
    </path>
    <animateMotion begin="mysvgline.begin" dur="800ms" repeatCount="1" path="M0 0C180.781 0 316.911 162 477 162" fill="freeze" />
  </g>
  <defs>
    <filter id="my-svg-filter0_d" x="130.225" y="40.416" width="291.046" height="120.176" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
      <feFlood flood-opacity="0" result="BackgroundImageFix" />
      <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
      <feOffset dy="4" />
      <feGaussianBlur stdDeviation="2" />
      <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.8 0" />
      <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow" />
      <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape" />
    </filter>
    <linearGradient id="my-svg-paint0_linear" x1="46.3904" y1="33" x2="501.658" y2="222.981" gradientUnits="userSpaceOnUse">
      <stop stop-color="#FFB916" />
      <stop offset="1" stop-color="#84F3DF" />
    </linearGradient>
  </defs>
</svg>
              
            
!

CSS

              
                body {
  background-color: #222;
  color: #fff;
  font-size: 2em;
  font-family: -apple-system, system-ui, sans-serif;
  padding: 1em;
}
              
            
!

JS

              
                if ('IntersectionObserver' in window)  {
  // Recommended: make this selector more specific with a `data-animate-on-visible`
  let elements = document.querySelectorAll("svg");

  let observer = new IntersectionObserver(entries => {
    // quit early if users wants Reduced Motion
    let mediaQuery = window.matchMedia('(prefers-reduced-motion: no-preference)');
    if(!mediaQuery.matches) {
      return;
    }

    for(let entry of entries) {
      if(!entry.isIntersecting) {
        continue;
      }

      // Look for <animate> or <animateTransform> that need JS to start
      let beginElements = entry.target.querySelectorAll(`:scope [begin="indefinite"]`);
      for(let beginEl of beginElements) {
        beginEl.beginElement();

        // Unobserve so we don’t re-animate the dead
        observer.unobserve(entry.target);
      }
    }
  },
  {
    threshold: .5 // 50% of element must be visible
  });

  for(let elem of elements) {
    observer.observe(elem);
  }
}
              
            
!
999px

Console