123

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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'>


            
          
!
            
              $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);
		}
	}
}


            
          
!
            
              // 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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console