Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <form action="">
  <input type="radio" name="winOrFail" value="win" />Win
  <input type="radio" name="winOrFail" value="fail" />Fail
</form>
<div class="progress-button elastic">
  <button><span>Submit</span></button>
  <svg class="progress-circle" width="70" height="70">
    <path d="m35,2.5c17.955803,0 32.5,14.544199 32.5,32.5c0,17.955803 -14.544197,32.5 -32.5,32.5c-17.955803,0 -32.5,-14.544197 -32.5,-32.5c0,-17.955801 14.544197,-32.5 32.5,-32.5z" stroke-dasharray="204.245 204.245" stroke-dashoffset="204.245"/>
  </svg>
  <svg class="checkmark" width="70" height="70">
    <path d="m31.5,46.5l15.3,-23.2" stroke-dasharray="27.80 27.80" stroke-dashoffset="27.80"/>
    <path d="m31.5,46.5l-8.5,-7.1" stroke-dasharray="11.7 11.7" stroke-dashoffset="11.7"/>
  </svg>
  <svg class="cross" width="70" height="70">
    <path d="m35,35l-9.3,-9.3"/>
    <path d="m35,35l9.3,9.3"/>
    <path d="m35,35l-9.3,9.3"/>
    <path d="m35,35l9.3,-9.3"/>
  </svg>
</div>

              
            
!

CSS

              
                body {
  font-family: 'Montserrat', sans-serif;
}

button {
  cursor: pointer;
}

/* Button container */
.progress-button {
	position: relative;
	display: inline-block;
	text-align: center;
	width: 45%;
	min-width: 250px;
	margin: 10px;
}

/* Button style */
.progress-button button {
	display: block;
	margin: 0 auto;
	padding: 0;
	width: 250px;
	height: 70px;
	border: 2px solid #1ECD97;
	border-radius: 40px;
	background: transparent;
	color: #1ECD97;
	letter-spacing: 1px;
	font-size: 18px;
	font-family: 'Montserrat', sans-serif;
	-webkit-tap-highlight-color: transparent;
	-webkit-transition: background-color 0.3s, color 0.3s, width 0.3s, border-width 0.3s, border-color 0.3s;
	transition: background-color 0.3s, color 0.3s, width 0.3s, border-width 0.3s, border-color 0.3s;
}

.progress-button button:hover {
	background-color: #1ECD97;
	color: #fff;
}

.progress-button button:focus {
	outline: none;
}

/* Text (transition for when returning to initial state) */
.progress-button button span {
	-webkit-transition: opacity 0.3s 0.1s;
	transition: opacity 0.3s 0.1s;
}

/* Common style of SVGs */
.progress-button svg {
	position: absolute;
	top: 0;
	left: 50%;
	-webkit-transform: translateX(-50%);
	transform: translateX(-50%);
	pointer-events: none;
}

.progress-button svg path {
	opacity: 0;
	fill: none;
}

.progress-button svg.progress-circle path {
	stroke: #1ECD97;
	stroke-width: 5;
}

.error.progress-button svg.progress-circle path {
	stroke: #FB797E;
	stroke-width: 5;
}

.progress-button svg.checkmark path,
.progress-button svg.cross path {
	stroke: #fff;
	stroke-linecap: round;
	stroke-width: 4;
	-webkit-transition: opacity 0.1s;
	transition: opacity 0.1s;
}

/* Loading, success and error effects */
.loading.progress-button button {
	width: 70px; /* make a circle */
	border-width: 5px;
	border-color: #ddd;
	background-color: transparent;
	color: #fff;
}

.loading.progress-button span {
	-webkit-transition: opacity 0.15s;
	transition: opacity 0.15s;
}

.loading.progress-button span,
.success.progress-button span,
.error.progress-button span {
	opacity: 0; /* keep it hidden in all states */
}

.success.progress-button button,
.error.progress-button button {
	-webkit-transition: background-color 0.3s, width 0.3s, border-width 0.3s;
	transition: background-color 0.3s, width 0.3s, border-width 0.3s;
}

.success.progress-button button {
	border-color: #1ECD97;
	background-color: #1ECD97;
}

.error.progress-button button {
	border-color: #FB797E;
	background-color: #FB797E;
}

.loading.progress-button svg.progress-circle path {
	opacity: 1;
	-webkit-transition: stroke-dashoffset 2s;
	transition: stroke-dashoffset 2s;
}

.success.progress-button svg.checkmark path,
.error.progress-button svg.cross path {
	opacity: 1;
	-webkit-transition: stroke-dashoffset 0.5s;
	transition: stroke-dashoffset 0.5s;
}

/* Optional elastic effect for the width of the button */
.elastic.progress-button button {
	-webkit-transition: background-color 0.3s, color 0.3s, width 0.3s cubic-bezier(0.25, 0.25, 0.4, 1), border-width 0.3s, border-color 0.3s;
	-webkit-transition: background-color 0.3s, color 0.3s, width 0.3s cubic-bezier(0.25, 0.25, 0.4, 1.6), border-width 0.3s, border-color 0.3s;
	transition: background-color 0.3s, color 0.3s, width 0.3s cubic-bezier(0.25, 0.25, 0.4, 1.6), border-width 0.3s, border-color 0.3s;
}

.loading.elastic.progress-button button {
	-webkit-transition: background-color 0.3s, color 0.3s, width 0.3s cubic-bezier(0.6, 0, 0.75, 0.75), border-width 0.3s, border-color 0.3s;
	-webkit-transition: background-color 0.3s, color 0.3s, width 0.3s cubic-bezier(0.6, -0.6, 0.75, 0.75), border-width 0.3s, border-color 0.3s;
	transition: background-color 0.3s, color 0.3s, width 0.3s cubic-bezier(0.6, -0.6, 0.75, 0.75), border-width 0.3s, border-color 0.3s;
}



              
            
!

JS

              
                /*
 * Forked from Colin Garven and Manoela Ilic on dribble:  https://dribbble.com/shots/1426764-Submit-Button
 * 
 * https://tympanus.net/codrops/2014/04/09/how-to-create-a-circular-progress-button/
 */

$('.progress-button button').click(function(){
  $('.progress-button').addClass('loading');
  draw('.progress-circle path');
  if( $('input:radio[name="winOrFail"]:checked').val() == "win" ){
    setTimeout(toggleSuccess, 2000);
  } else {
    setTimeout(toggleError, 2000);
  }
});

var toggleSuccess = function(){
  $('.progress-button').addClass('success');
  draw('.checkmark path');
  setTimeout(function(){
    $('.progress-button')
      .removeClass('success')
      .removeClass('loading');
    resetDashes();
  },2000);
};

var toggleError = function(){
  $('.progress-button').addClass('error');
  draw('.cross path');
  setTimeout(function(){
    $('.progress-button')
      .removeClass('error')
      .removeClass('loading');
    resetDashes();
  },2000);
}; 

function draw(loc) {
  var paths = document.querySelectorAll(loc);
  console.log(paths);
  for( var i = 0; i < paths.length; i++ ){
    paths[i].style.strokeDashoffset = '0';
  }
}

function resetDashes() {
  var paths = document.querySelectorAll('path');
  for( var i = 0; i < paths.length; i++ ){
    var path = paths[i];
      var length = path.getTotalLength();
      path.style.strokeDasharray = length + ' ' + length;
      path.style.strokeDashoffset = length;
  }
}

$(document).ready(function(){
  // fire it on load just for a demo
  $('.progress-button button').click();
});
              
            
!
999px

Console