Progress bars are widely used on websites to highlight specific data in a more appealing way for users. One benefit of using a circle progress bar over a regular (horizontal) progress bar is that you can fit more progress bars in one row, thus displaying more data to the user.
I’ve already covered how you can style a progress bar in my earlier article. But now we’re going to look at how you can create a circle progress bar.
Setup
To display a circle progress bar with CSS we want to use as few HTML elements as possible. A proper way to show a progress bar is to use a semantic HTML element called progress.
However, it has specific default styles which make its unique appearance, thus preventing us from using all available CSS properties and displaying it as a circle.
As an alternative, we can use a div element with a progressbar role.
So to create a circle progress bar with only CSS we will need to use a div element anyway. There are two options for the markup.
Option 1
The first option is to use a regular div with a progressbar role along with additional ARIA attributes such as aria-valuenow , aria-valuemin , and aria-valuemax to indicate the range of the progress bar. HTML looks as follows:
The second option is to wrap a progress element inside a div and hide it with CSS. That way we use a native progress element that will still be accessible in the DOM (just visually hidden) and the div will act as a visual representation. HTML looks as follows:
Since in both HTML approaches we will be styling a div element to create a circular progress bar, we’re going to use gradients. For the background property, we’ll set a radial-gradient function and a conic-gradient function that is available in CSS.
The conic-gradient will show the actual progress (the current value) and the radial-gradient will act as a mask on top of the conic-gradient .
To break it down. The conic-gradient function accepts multiple parameters (steps). In our case it is two steps, the first one will start at 0 degrees (12 o’clock) and span all the way up to 75% of the circumference of the circle (9 o’clock).
The radial-gradient in our case represents the mask, and consists of a white color (to match the background) and transparent color to show the progress bar.
The first parameter of the radial-gradient function is the size of the gradient’s ending shape, in our case, it is equal to the closest-side . Meaning the gradient’s ending shape meets the side of the box closest to its center.
After the size of radial-gradient , we specify the color and size of our mask (white overlay) white 79% and transparent color to take up the remaining size of the circle transparent 80% 100% . The one percent difference (79% and 80%) is made to smooth out the border of the gradient.
Browser compatibility for conic-gradient function:
Browser compatibility for radial-gradient function:
Showing the percentage
Additionally, let’s display a percentage value in the middle of the circle to inform users about the exact value of our progress bar.
To do so, we can use a pseudo-element with a content property. As for the progress bar div , we’ll need to set additional properties to center the percentage, flex in this case.
💡 NOTE: The animation of such a progress bar will only work in Chromium-based browsers.
To make the progress bar animate, we’ll need to specify the value inside a CSS variable, and then change its value inside the animation.
We must use @property rule to use the variable value inside the animation, but like I said previously, this way we are limited to Chromium based browsers.
Specifying CSS variables in a traditional way like —progress-value: 0 won’t work inside the animation, as per specification they are not animatable.
Browser compatibility for @property rule:
We’ll need to change the percentage value to a calc() function to calculate the percentage for the conic-gradient .
Finally, let’s animate the percentage value along with the progress bar. We will do it in a similar fashion. We’ll use existing CSS variable and set it equal to a pseudo-element counter property, as well as specify the animation property.
While pure CSS solution for circle progress bar is easy to implement it lacks additional customization. For the most part you can only control the width and color of the bar.
Another aspect of this solution, is that it’s not yet fully supported by all browsers, the animation to be exact. So if you’re considering a bulletproof way to display a circle progress bar with animation and possible customizations, you’d might want to use SVG solution.
Finally the end result with complete code can be viewed on CodePen:
See the Pen Untitled by Nikita Hlopov (@nikitahl) on CodePen.
Experiment with a new value for the CSS position property to create a progress bar reading the articles without the need of using PHP or JavaScript, just HTML and CSS.
24 Best Free CSS Progress Bars That You Can Use In 2023
CSS Progress Bars are a great way to show progress and provide feedback to users. They can be used for a variety of purposes, from indicating the amount of time left on a task to showing the completion of a process.
With the help of CSS Progress Bars code examples, you can easily create visually appealing and interactive progress bars that will make your website or application more user-friendly.
In this article, we have listed the best free HTML and CSS progress bars with demo and download link. So, you can use these code examples for designing your website.
1. Purple Progress Bar
Purple Progress Bar Made By: Jasper
2. Bars
3. CSS Circular Progress
CSS Circular Progress Made By: Mattia Astorino
4. Stepped Progress
Stepped Progress Made By: Cassidy
5. SVG Circle Progress Bar
SVG Circle Progress Bar Made By: Ekta maurya
6. Warning Bar
Warning Bar Made By: Morgan
7. Color Changing Loading Progress Bar
Color Changing Loading Progress Bar Made By: rachelmckean
8. Only SCSS Loading Animation
Only SCSS Loading Animation Made By: Tobias Glaus
9. Interactive Progress Bar Pure CSS
Interactive Progress Bar Pure CSS Made By: Jenning
10. Progress
Progress Made By: Ychnightder-both
11. SVG Circle Progress Bar
SVG Circle Progress Bar Made By: Ekta maurya
12. Rainbow Progress Bar
Rainbow Progress Bar Made By: Antoinette Janus
13. Light Progress Bar
Light Progress Bar Made By: FEAR ØF CODE
14. Dribbble Recreation: Loading Bar
Dribbble Recreation: Loading Bar Made By: Antoinette Janus
15. Loading Bar
Loading Bar Made By: Artboard Artisan
16. Pure CSS Progress
Pure CSS Progress Made By: Rafael González
17. WebKit Progress Scrollbar [CSS Only]
WebKit Progress Scrollbar [CSS Only] Made By: Myk
18. Reading Progess Bar CSS Only
Reading Progess Bar CSS Only Made By: Ricardo Prieto
19. Expanding Loader
Expanding Loader Made By: Eric Gregoire
20. Orb Progress Bar
Orb Progress Bar Made By: Ben Anderson
21. Static Progress Bar VS Progress Bar
Static Progress Bar VS Progress Bar With Opposing Animation Made By: Kevin Sweeney