JSFiddle - React, Tailwind, and code Playground

by Steven Senkus

HTML

<script src="http://tympanus.net/Development/ProgressButtonStyles/js/classie.js"></script>
<script src="http://tympanus.net/Development/ProgressButtonStyles/js/progressButton.js"></script>
<script src="http://tympanus.net/Development/ProgressButtonStyles/js/modernizr.custom.js"></script>

<button class="progress-button" data-style="rotate-angle-bottom" data-perspective data-horizontal>
    <span class="progress-wrap">
        <span class="content">Submit</span>
        <span class="progress">
            <span class="progress-inner"></span>
        </span>
    </span>
</button>

<button class="progress-button" data-style="fill" data-horizontal>
    <span class="content">Submit</span>
    <span class="progress">
        <span class="progress-inner"></span>
    </span>
</button>

CSS

*, *:after, *::before { box-sizing: border-box; }
 
@font-face {
    font-weight: normal;
    font-style: normal;
    font-family: 'icomoon';
    src:url('../fonts/icomoon/icomoon.eot');
    src:url('../fonts/icomoon/icomoon.eot?#iefix') format('embedded-opentype'),
        url('../fonts/icomoon/icomoon.ttf') format('truetype'),
        url('../fonts/icomoon/icomoon.woff') format('woff'),
        url('../fonts/icomoon/icomoon.svg#icomoon') format('svg');
}
 
.progress-button {
    position: relative;
    display: inline-block;
    padding: 0 60px;
    outline: none;
    border: none;
    background: #1d9650;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 1em;
    line-height: 4;
}
 
.progress-button[disabled],
.progress-button[disabled].state-loading {
    cursor: default;
}
 
.progress-button .content {
    position: relative;
    display: block;
}
 
.progress-button .content::before,
.progress-button .content::after  {
    position: absolute;
    right: 20px;
    color: #0e7138;
    font-family: "icomoon";
    opacity: 0;
    transition: opacity 0.3s 0.3s;
}
 
.progress-button .content::before {
    content: "\e600"; /* Checkmark for success */
}
 
.progress-button .content::after {
    content: "\e601"; /* Cross for error */
}
 
.progress-button.state-success .content::before,
.progress-button.state-error .content::after {
    opacity: 1;
}
 
.notransition {
    transition: none !important;
}
 
.progress-button .progress {
    background: #148544;
}
 
.progress-button .progress-inner {
    position: absolute;
    left: 0;
    background: #0e7138;
}
 
.progress-button[data-horizontal] .progress-inner {
    top: 0;
    width: 0;
    height: 100%;
    transition: width 0.3s, opacity 0.3s;
}
 
.progress-button[data-vertical] .progress-inner {
    bottom: 0;
    width: 100%;
    height: 0;
    transition: height 0.3s, opacity 0.3s;
}
 
/* Necessary styles for buttons with 3D transforms */
 
.progress-button[data-perspective]...

JavaScript

[].slice.call( document.querySelectorAll( 'button.progress-button' ) ).forEach( function( bttn ) {
				new ProgressButton( bttn, {
					callback : function( instance ) {
						var progress = 0,
							interval = setInterval( function() {
								progress = Math.min( progress + Math.random() * 0.1, 1 );
								instance._setProgress( progress );

								if( progress === 1 ) {
									instance._stop(1);
									clearInterval( interval );
								}
							}, 200 );
					}
				} );
			} );