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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <h1>Slider Circular Progress Bar using SVG</h1>
<div class="circular-progress">
	<svg 
		xmlns='http://www.w3.org/2000/svg'
		viewBox='0 0 100 100'
		aria-labelledby='title' role='graphic'>
		<title id='title'>svg circular progress bar</title>
		<circle cx="50" cy="50" r="40" ></circle>
		<circle cx="50" cy="50" r="40" id='pct-ind'></circle>
	</svg>
	<p class="pct">70%</p>
</div>

<label for="slider" class='sr-only'>range slider</label>
<input type="range" class="custom-range" id='slider' value='70'>


              
            
!

CSS

              
                $circle-circumstance: ( 2 * (22 / 7) * 40 );

body {
	text-align: center;
	padding-top: 40px;
}

.circular-progress { 
	margin-top: 60px;
	position: relative;
	display: inline-block;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  svg {
    transform: rotate(270deg);
  }
  circle {
    stroke-width: 5;
    fill: none;
		stroke-linecap: round;
  }
  circle:nth-of-type(1) {
    stroke: #dee2e6;
  }
  circle:nth-of-type(2) {
    stroke: #d8503a;
    stroke-dasharray: $circle-circumstance;
		
		// here we multiply the circle circumstance by an opposite number of what we want it to present
		// so here we want it to present 70% which means 0.7 and the opposite of that is 0.3 ( 1 - 0.7 )
    stroke-dashoffset: ( 0.3 * $circle-circumstance );
  }
	
	.pct {
		margin: 0;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate( -50% , -50% );
	}
}

// the code under below is just to chnage bootstrap css custom range color ( the color of the thumb )
#slider {
	margin: 0 50px;
	width: 50%;
	&::-moz-range-thumb {
		background-color: #d8503a;
	}
	&::-webkit-slider-thumb {
		background-color: #d8503a;
	}
	&::-ms-thumb {
		background-color: #d8503a;
	}
	
	&:focus {
		&::-moz-range-thumb {
			box-shadow: 0 0 0 1px #fff, 0 0 0 0.2rem rgba(#d8503a, 0.25);

		}
		&::-webkit-slider-thumb {
			box-shadow: 0 0 0 1px #fff, 0 0 0 0.2rem rgba(#d8503a, 0.25);
		}
		&::-ms-thumb {
			box-shadow: 0 0 0 1px #fff, 0 0 0 0.2rem rgba(#d8503a, 0.25);
		}
	}
}


              
            
!

JS

              
                // FOLLOW ME @IamAhmedHamed

const slider = document.querySelector('#slider');
const pct = document.querySelector('.pct');
const pctIndicator = document.querySelector('#pct-ind')
slider.oninput = () => {
	pct.textContent = `${slider.value}%`
	
	// percent for dashoffset
	const p = ( 1 - slider.value / 100 ) * (2 * (22 / 7) * 40);
	pctIndicator.style = `
		stroke-dashoffset: ${p};    
	`
}

              
            
!
999px

Console