Skip to content

Instantly share code, notes, and snippets.

@gazpachu
Last active May 20, 2022 06:56
Show Gist options
  • Save gazpachu/bb72d02c83280f08abd9278cfdb9d8f0 to your computer and use it in GitHub Desktop.
Save gazpachu/bb72d02c83280f08abd9278cfdb9d8f0 to your computer and use it in GitHub Desktop.
Pure CSS Animated Circular Progress Bar
<Progress>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-1 -1 34 34">
<ProgressSurface cx="16" cy="16" r="15.9155" />
<ProgressBar
cx="16"
cy="16"
r="15.9155"
strokeDashoffset={percentProgress}
/>
</svg>
<ProgressText>{`${percentProgress}%`}</ProgressText>
</Progress>
export const Progress = styled.div`
display: flex;
align-items: center;
justify-content: center;
svg {
height: 200px;
width: 200px;
transform: rotate(-90deg);
overflow: visible;
}
`;
export const ProgressSurface = styled.circle`
fill: none;
stroke: ${({ theme }) => theme.colors.canvas};
stroke-width: 4;
`;
export const ProgressBar = styled.circle`
fill: none;
stroke: ${({ theme }) => theme.colors.primary};
stroke-width: 4;
stroke-dasharray: 100 100;
stroke-linecap: round;
transition: stroke-dashoffset 1s ease-in-out;
`;
export const ProgressText = styled.div`
position: absolute;
`;
@gazpachu
Copy link
Author

Preview:

Screen Shot 2022-05-20 at 15 56 34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment