cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              .wrapper {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100vh;
}

// same animation used for both components
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

// SVG Spinner code below
svg {
  height: 20vw;
}

// LESS Spinner code below

// Monochrome
@color-lightest: #fff;
@color-medium: #CCC;
@color-mediumdark: #999;

:root {
  --darkBlue: #3f51b5;
}

.generate-spinner-ticks(@n, @i: 1) when (@i =< @n) {
  .spinner-tick:nth-child(@{i}) {
    transform: rotate((@i * 360deg / @n));

    &:before {
      animation-delay: (-1600ms * (@i - 1)) / @n;
    }
  }

  .generate-spinner-ticks(@n, (@i + 1));
}

.loading-spinner {
  @spinner-speed: 1600ms;

  @spinner-color-primary: var(--darkBlue);
  @spinner-color-primary-alt: @color-lightest;

  @spinner-color-secondary: @color-mediumdark;
  @spinner-color-secondary-alt: @color-medium;

  @spinner-dimension-l: 80px;
  @spinner-tick-length-l: 6px;
  @spinner-wheel-dimension-l: @spinner-dimension-l - @spinner-tick-length-l -
    12px;

  @spinner-dimension-m: 48px;
  @spinner-tick-length-m: 4px;
  @spinner-wheel-dimension-m: @spinner-dimension-m - @spinner-tick-length-m -
    10px;

  @spinner-dimension-s: 32px;
  @spinner-tick-length-s: 4px;
  @spinner-wheel-dimension-s: @spinner-dimension-s - @spinner-tick-length-s -
    8px;

  display: inline-block;
  position: relative;
  vertical-align: top;

  .spinner-ticks {
    .generate-spinner-ticks(16);
    position: relative;

    height: @spinner-dimension-s;
    width: @spinner-dimension-s;

    .spinner-tick {
      .position(absolute, auto, 50%, auto, auto, 1px, 100%);
      transform-origin: center;

      &:before,
      &:after {
        .position(absolute, 0, auto, auto, auto, 1px, @spinner-tick-length-s);
        content: '';
        display: block;

        background: fade(@spinner-color-primary-alt, 20%);
      }

      &:before {
        animation: glow-loading @spinner-speed infinite linear;
        opacity: 1;
        z-index: 1;

        background: @spinner-color-primary;
      }
    }
  }

  .spinner-wheel {
    animation: spin @spinner-speed infinite linear;
    .position(absolute, 50%, 50%);
    z-index: 1;

    margin-top: -@spinner-wheel-dimension-s/2;
    margin-right: -@spinner-wheel-dimension-s/2;
    height: @spinner-wheel-dimension-s;
    width: @spinner-wheel-dimension-s;

    border: 1px solid transparent;
    border-top: 1px solid @spinner-color-primary;
    border-right: 1px solid @spinner-color-primary;
    border-radius: 3em;
  }

  // Secondary colorway
  &.secondary {
    .spinner-tick {
      &:after {
        background: fade(@spinner-color-secondary-alt, 20%);
      }
      &:before {
        background: @spinner-color-secondary;
      }
    }
    .spinner-wheel {
      border-top-color: @spinner-color-secondary;
      border-right-color: @spinner-color-secondary;
    }
  }

  // Sizes
  &.medium {
    .spinner-ticks {
      .generate-spinner-ticks(24);
      height: @spinner-dimension-m;
      width: @spinner-dimension-m;

      .spinner-tick:before,
      .spinner-tick:after {
        height: @spinner-tick-length-m;
      }
    }

    .spinner-wheel {
      margin-top: -@spinner-wheel-dimension-m/2;
      margin-right: -@spinner-wheel-dimension-m/2;
      height: @spinner-wheel-dimension-m;
      width: @spinner-wheel-dimension-m;
    }
  }

  &.large {
    .spinner-ticks {
      .generate-spinner-ticks(32);
      height: @spinner-dimension-l;
      width: @spinner-dimension-l;

      .spinner-tick:before,
      .spinner-tick:after {
        height: @spinner-tick-length-l;
      }
    }
    .spinner-wheel {
      margin-top: -@spinner-wheel-dimension-l/2;
      margin-right: -@spinner-wheel-dimension-l/2;
      height: @spinner-wheel-dimension-l;
      width: @spinner-wheel-dimension-l;
    }
  }
}

.position(@type; @top: auto; @right: auto; @bottom: auto; @left: auto; @width: auto; @height: auto) {
  position: @type;
  top: @top;
  right: @right;
  bottom: @bottom;
  left: @left;
  width: @width;
  height: @height;
}

.animation(...) {
  @process: ~`(function(t){return t=t||"none",/^[^, ]*,/.test(t)&&(t=t.replace(/(?:,)(?![^(]*\))/g,"")),t})((function(){var t="@{arguments}";return t=t.replace(/^\[|\]$/g,"")})())`;
  -webkit-animation: @process;
  -moz-animation: @process;
  -o-animation: @process;
  animation: @process;
}

.animation-delay(...) {
  @process: ~`(function(t){t=t||"0";var r=/(?:\d)(?:ms|s)/gi,e=/(?:\s|^)(\.?\d+\.?\d*)(?![^(]*\)|\w|%|\.)/gi;return r.test(t)||"0"===t||(t=t.replace(e,function(t){return t+=parseFloat(t,10)>10?"ms":"s"})),t})((function(){var t="@{arguments}";return t=t.replace(/^\[|\]$/g,"")})())`;
  -webkit-animation-delay: @process;
  -moz-animation-delay: @process;
  -o-animation-delay: @process;
  animation-delay: @process;
}

.transform(...) {
  @process: ~`(function(e){e=e||"none";var r={translate:"px",rotate:"deg",rotate3d:"deg",skew:"deg"};/^\w*\(?[a-z0-9.]*\)?/.test(e)&&(e=e.replace(/(?:,)(?![^(]*\))/g,""));for(var t in r)e.indexOf(t)>=0&&(e=e.replace(new RegExp(t+"[\\w]?\\([a-z0-9, %]*\\)"),function(e){var n=/(\d+\.?\d*)(?!\w|%)/g;return"rotate3d"==t&&(n=/,\s*\d+$/),e.replace(n,function(e){return e+r[t]})}));return e})((function(){var e="@{arguments}";return e=e.replace(/^\[|\]$/g,"")})())`;
  -webkit-transform: @process;
  -moz-transform: @process;
  -o-transform: @process;
  -ms-transform: @process;
  transform: @process;
}

.transform-origin(...) {
  @process: ~`(function(e){e=e||"50% 50% 0";var r=/\d/gi,t=/(?:\s|^)(\.?\d+\.?\d*)(?![^(]*\)|\w|%|\.)/gi;return/^[^, ]*,/.test(e)&&(e=e.replace(/(?:,)(?![^(]*\))/g,"")),r.test(e)&&(e=e.replace(t,function(e){return 0==e&&e||e+"%"})),e})((function(){var e="@{arguments}";return e=e.replace(/^\[|\]$/g,"")})())`;
  -webkit-transform-origin: @process;
  -moz-transform-origin: @process;
  -o-transform-origin: @process;
  -ms-transform-origin: @process;
  transform-origin: @process;
}


.glow-loading() {
  // Loading Spinner ticks
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@-webkit-keyframes glow-loading { .glow-loading; }
@keyframes glow-loading { .glow-loading; }
            
          
!
            
              const definitions = [
  // bottom left rectangle
  { x: 0, y: 60, start: 0.5, end: 0 },
  // top left rectangle
  { x: 0, y: 0, start: 0.5, end: 0.75 },
  // top right rectangle
  { x: 60, y: 0, start: 0.75, end: 0.9 },
  // bottom right rectangle
  { x: 60, y: 60, start: 0.9, end: 1 },
];

const animation = 'spin 1.6s linear infinite';

const OpticalGradient = props => {
  return props.definitions.map(({ x, y, start, end, transformOrigin }) => [
    <linearGradient id={`gradient-${x}-${y}`} key="gradient">
      <stop offset="0%" stopColor="#fff" stopOpacity={start} />
      <stop offset="100%" stopColor="#fff" stopOpacity={end} />
    </linearGradient>,
    <rect
      key="rectangle"
      x={x}
      y={y}
      width={60}
      height={60}
      fill={`url(#gradient-${x}-${y})`}
      style={{
        animation: `${animation} reverse -0.2s`,
        transformOrigin: `60px 60px`,
      }}
    />,
  ]);
};

const LoadingSpinnerSVG = () => {
  return (
    <svg viewBox="0 0 120 120" fill="transparent">
      <circle
        r={42}
        cx={60}
        cy={60}
        stroke="#133C99"
        strokeWidth={6}
        strokeDasharray="2 9.5"
      />
      <OpticalGradient definitions={definitions} />
      <linearGradient id="arc-gradient">
        <stop offset="0%" stopOpacity="0" />
        <stop offset="49.99%" stopOpacity="0" />
        <stop offset="50%" stopColor="#133C99" />
        <stop offset="100%" stopColor="#133C99" />
      </linearGradient>
      <circle
        r={36}
        cx={60}
        cy={60}
        fill="transparent"
        stroke="url(#arc-gradient)"
        strokeWidth={2}
        style={{
          animation,
          transformOrigin: `60px 60px`,
        }}
      />
    </svg>
  );
};

// --------------------------------------------------


const LoadingSpinnerPreprocessor = () => {
  const ticks = [];
  for (var i = 0; i < 24; i++) {
    ticks.push(<div key={i} className="spinner-tick" />);
  }
  return (
    <div className={`loading-spinner medium`} style={{ transform: "scale(2)" }}>
      <div className="spinner-wheel" />
      <div className="spinner-ticks">{ticks}</div>
    </div>
  );
};

ReactDOM.render(
  <div className="wrapper">
    <div><LoadingSpinnerSVG /></div>
    <div><LoadingSpinnerPreprocessor /></div>
  </div>,
  document.getElementById("root")
);

            
          
!
999px
Loading ..................

Console