Pen Settings



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


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.


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.


  viewBox="0 0 1000 1000" 
    A geometric pattern composed of nested circles and squiggly lines.
    Inspired by Legends of Zelda: Tears of the Kingdom
  <text text-anchor="middle" y="500" x="500" style="font-size: 2em; font-family: sans-serif;">Tap anywhere on the SVG canvas to add circle groups</text>

  <g class="pattern">
      Our graphics code goes here 


                html, body {
  display: grid;
  place-items: center;
  min-height: 100%;
  background-color: #eee;

svg {
  background: #fff;
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;

.filled-circle {
  fill: #fff;

.stroked-circle {
  fill: none;
  stroke: #999;
  stroke-width: 10;


                import { randomInt } from '';

function circle({ x, y, r, className }) {
  return `

function circleGroup({x, y, r }) {
  // We'll store all our circles in an array.
  const circles = [];

  // First, draw a circle with a white background but no border.
  // This will hide any elements behind the circle.
  circles.push(circle({ x, y, r, className: 'filled-circle' }));

  // Decide how much space to put between our circles.
  const gap = 20;

  // Draw a number of circles, making each one smaller than the last
  // until we hit a radius of 0.
  let circleSize = r;
  while(circleSize > 0) {
    circles.push(circle({ x, y, r: circleSize, className: 'stroked-circle' }));
    circleSize -= gap;

  // Return all our circles as a single string;
  return circles.join('');

const patternEl =  document.querySelector('.pattern');
const svgEl =  document.querySelector('svg');

svgEl.addEventListener('click', (e) => {
  const { x, y } = getClickOnSvg(e);
  patternEl.innerHTML += circleGroup({
    r: randomInt(100, 400),

function getClickOnSvg(e) {
  let pt = DOMPoint.fromPoint(svgEl); 
  pt.x = e.clientX;
  pt.y = e.clientY;

    // The cursor point, translated into svg coordinates
  return  pt.matrixTransform(svgEl.getScreenCTM().inverse());