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.

+ 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.


    <div class="spinner" data-options="large  blue" style="background-color:#eee" role="progressbar" aria-valuetext="Loading…"></div>
    <h1>Simple <br><code>&lt;paper-spinner&gt;</code></h1>
    <p>Intrigued by Keanu Lee's brilliant <a href="//">article</a> describing how he built the official <a href="//"><code>&lt;paper-spinner&gt;</code> Polymer element</a> seen in the <a href="//">Google Material Design spec</a>, I had to see if it was possible to simplify the spinner further by condensing it down to a single HTML element. My goal was to rebuild the paper-spinner in a way that was:</p>
        <li>Accessible ✓</li>
        <li>Cross browser compatible (IE10+) ✓<a href="#note-1">*</a></li>
        <li>A single HTML element ✓</li>
        <li>HTML and CSS only ✓</li>
        <li>Uses relative units for easy scalability ✓</li>
        <li>Animated with strictly composite properties (<code>transform</code> and <code>opacity</code>) ✓<a href="#note-2">**</a></li>
    <p>Well…I got really close. Check it out. (Pull requests are more than welcome.)</p>

    <div class="spinner" role="progressbar" aria-valuetext="Loading…"></div>
    <pre><code><mark>&lt;div class="spinner" role="progressbar" aria-valuetext="Loading…"&gt;&lt;/div&gt;</mark></code></pre>

    <h2>Preset colors</h2>
    <div class="spinner" data-options="blue" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="red" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="yellow" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="green" role="progressbar" aria-valuetext="Loading…"></div>
    <pre><code>&lt;div class="spinner" <mark>data-options="blue"</mark> role="progressbar" aria-valuetext="Loading…"&gt;&lt;/div&gt;</code></pre>

    <h2>Preset sizes</h2>
    <div class="spinner" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="large" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="xlarge" role="progressbar" aria-valuetext="Loading…"></div>
    <pre><code>&lt;div class="spinner" <mark>data-options="large"</mark> role="progressbar" aria-valuetext="Loading…"&gt;&lt;/div&gt;</code></pre>

    <h2>Completely custom</h2>
    <div class="spinner" data-options="blue" style="font-size:71px;box-shadow: inset 0 0 0 2px" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="red" style="box-shadow:inset 0 0 0 1px" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="yellow" style="box-shadow:inset 0 0 0 6px" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" style="color:#f06;background-color:#afa" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="blue" style="box-shadow:inset 0 0 0 .1875em,inset 0 0 0 .375em #db4437,inset 0 0 0 .5625em #f4b400,inset 0 0 0 .75em #0f9d58" role="progressbar" aria-valuetext="Loading…"></div>
    <pre><code>&lt;div class="spinner" data-options="blue" <mark>style="font-size:71px;box-shadow:inset 0 0 0 2px"</mark> role="progressbar" aria-valuetext="Loading…"&gt;&lt;/div&gt;</code></pre>

    <button class="toggle-multicolor">Toggle multicolor (invokes repaints)</button>
    <div class="spinner  is-active" data-options="multicolor" role="progressbar" aria-valuetext="Loading…"></div>
    <pre><code>&lt;div class="spinner" <mark>data-options="multicolor"</mark> role="progressbar" aria-valuetext="Loading…"&gt;&lt;/div&gt;</code></pre>

    <h2>How it's done</h2>
    <div class="spinner" data-options="debug  debug--1" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="debug  debug--2" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner" data-options="debug  debug--3" role="progressbar" aria-valuetext="Loading…"></div>
    <div class="spinner  is-active" data-options="multicolor  debug  debug--4" role="progressbar" aria-valuetext="Loading…"></div>

    <h2>Outstanding resources</h2>
        <li><a href="//"></a></li>
        <li><a href="//"> (&lt;paper-spinner&gt;)</a></li>
        <li><a href="//"> (high performance animations)</a></li>
        <li><a href="//"> (translate animations)</a></li>
        <li><a href="//">MDN (transform)</a></li>
        <li><a href="//"> (IE10 bug)</a></li>
    <p id="note-1">*I use <code>clip-path: circle()</code>, which is not available in IE or Firefox, as a progressive enhancement only to remove small artifacts left over from the animations.</p>
    <p id="note-2">**All spinners animate with composite properties except the multicolor spinner. The multicolor spinner unfortunately invokes repaints on color changes. :/ On the plus side, I haven't seen the frame rate dip below 60fps.</p>

    <small>Built by <a href="//">@chrisnager</a> &middot; <a href="//">GitHub</a> &middot; <a href="//">CodePen</a></small>


                /* Spinner rotation */
@keyframes spin { to { transform: rotate(1080deg) } }

.spinner {
    width: 1.75em;
    height: 1.75em;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 .1875em;
    will-change: transform;
    animation: spin 2666ms linear infinite;
    clip-path: circle(.875em at center);

    /* Set background to same color as pseudo elements. Defaults to white */
    background-color: #fff;

/* Preset colors */
.spinner[data-options*="blue"] { color: #4285f4 }
.spinner[data-options*="red"] { color: #db4437 }
.spinner[data-options*="yellow"] { color: #f4b400 }
.spinner[data-options*="green"] { color: #0f9d58 }

/* Preset sizes */
.spinner[data-options*="large"] { font-size: 2em }
.spinner[data-options*="xlarge"] { font-size: 3em }

/* Multicolor */
@keyframes color-shift {
    /* Blue */
    from { box-shadow: inset 0 0 0 .1875em #4285f4 }
    22% { box-shadow: inset 0 0 0 .1875em #4285f4 }

    /* Red */
    23% { box-shadow: inset 0 0 0 .1875em #db4437 }
    48% { box-shadow: inset 0 0 0 .1875em #db4437 }

    /* Yellow */
    49% { box-shadow: inset 0 0 0 .1875em #f4b400 }
    73% { box-shadow: inset 0 0 0 .1875em #f4b400 }

    /* Green */
    74% { box-shadow: inset 0 0 0 .1875em #0f9d58 }
    98% { box-shadow: inset 0 0 0 .1875em #0f9d58 }

    /* Back to blue */
    to { box-shadow: inset 0 0 0 .1875em #4285f4 }

/* Forced to duplicate `spin` keyframes for multicolor spinner.
 * Otherwise, spinner continues to rotate without resetting to account for color changes */
@keyframes multicolor-spin { to { transform: rotate(1080deg) } }

.spinner[data-options*="multicolor"] { will-change: transform, box-shadow }
.spinner[data-options*="multicolor"].is-active { animation: multicolor-spin 2666ms linear infinite, color-shift 8531.2ms infinite linear }

.spinner::after {
    content: "";
    position: absolute;
    width: 7em;
    height: 1.75em;
    background-color: inherit;

@keyframes shape-shift-before { to { transform: skewX(-45deg) translate(.875em, -.875em) } }

.spinner::before {
    transform: skewX(80deg) translate(.875em, -.875em);
    animation: shape-shift-before 1066.4ms cubic-bezier(.4, 0, .2, 1) infinite alternate;

@keyframes shape-shift-after { to { transform: skewX(45deg) translate(.875em, .875em) } }

.spinner::after {
    transform: skewX(-80deg) translate(.875em, .875em);
    animation: shape-shift-after 1066.4ms cubic-bezier(.4, 0, .2, 1) infinite alternate;

/* Debug */
.spinner[data-options*="debug"] {
    margin-top: 1em;
    margin-bottom: 1em;

.spinner[data-options*="debug"]::before { background-color: rgba(255, 0, 0, .75) }
.spinner[data-options*="debug"]::after { background-color: rgba(0, 0, 255, .75) }

.spinner[data-options*="debug--1"] {
    margin-right: 7em;
    overflow: visible;
    clip-path: none;

.spinner[data-options*="debug--2"] { animation: none }

/* Docs */
body{margin:0;font:300 1em/1.4 "Helvetica Neue",sans-serif;color:#114}header,main,footer{padding:2em}header,footer{background-color:#eee}h1,h2{font-weight:500}a{text-decoration:none;color:#0f9d58}a:hover,a:focus{text-decoration:underline}ul{padding-left:30px}@media(min-width:30em){br{display:none}}button{border:1px solid;border-radius:.25em;font-size:.75em;cursor:pointer;display:block;box-sizing:border-box;padding:1em;margin:1em 0;height:auto;vertical-align:middle;-webkit-appearance:none;color:#0f9d58;background-color:transparent}button:hover,button:focus{border-color:#0f9d58;color:#fff;background-color:#0f9d58}pre{border:2px solid;border-radius:3px;padding:1em;white-space:pre-wrap}mark{background-color:rgba(244,180,0,.3)}


                document.querySelector('.toggle-multicolor').addEventListener('click', function() {
    var multicolorSpinners = document.querySelectorAll('[data-options*="multicolor"]');, function(multicolorSpinner) {