Progress circle
A circular progress indicator with the percentage inside, or an indeterminate spinner, on a native progress element.
Installation
bash
npx bootcn add progress-circlebash
pnpm dlx bootcn add progress-circlebash
yarn dlx bootcn add progress-circlebash
bunx --bun bootcn add progress-circleThe CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.
Usage
Set the value with the --bootcn-progress custom property (0–100) and keep the hidden <progress> in sync: it carries the value for screen readers. Leave out the value for work of unknown length. Sizes: --sm, default, --lg, or set --bootcn-progress-size.
Accessibility
- A visually hidden native
<progress>with a name carries the value; the ring and the number are decorative. - The indeterminate spinner slows down under reduced motion (it does not stop, so loading is still visible).
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.
Source
The exact files the CLI installs (progress-circle@1.0.0). View on GitHub · Report an issue
html
<div class="d-flex flex-wrap align-items-center gap-4">
<div class="bootcn-progress-circle bootcn-progress-circle--sm" style="--bootcn-progress: 25">
<progress class="visually-hidden" max="100" value="25" aria-label="Upload">25%</progress>
<svg viewBox="0 0 36 36" aria-hidden="true" focusable="false">
<circle class="bootcn-progress-circle__track" cx="18" cy="18" r="15.9155" pathLength="100" />
<circle class="bootcn-progress-circle__value" cx="18" cy="18" r="15.9155" pathLength="100" />
</svg>
<span class="bootcn-progress-circle__label" aria-hidden="true">25%</span>
</div>
<div class="bootcn-progress-circle" style="--bootcn-progress: 65">
<progress class="visually-hidden" max="100" value="65" aria-label="Course completed">
65%
</progress>
<svg viewBox="0 0 36 36" aria-hidden="true" focusable="false">
<circle class="bootcn-progress-circle__track" cx="18" cy="18" r="15.9155" pathLength="100" />
<circle class="bootcn-progress-circle__value" cx="18" cy="18" r="15.9155" pathLength="100" />
</svg>
<span class="bootcn-progress-circle__label" aria-hidden="true">65%</span>
</div>
<div class="bootcn-progress-circle bootcn-progress-circle--lg" style="--bootcn-progress: 90">
<progress class="visually-hidden" max="100" value="90" aria-label="Profile">90%</progress>
<svg viewBox="0 0 36 36" aria-hidden="true" focusable="false">
<circle class="bootcn-progress-circle__track" cx="18" cy="18" r="15.9155" pathLength="100" />
<circle class="bootcn-progress-circle__value" cx="18" cy="18" r="15.9155" pathLength="100" />
</svg>
<span class="bootcn-progress-circle__label" aria-hidden="true">90%</span>
</div>
<div class="bootcn-progress-circle bootcn-progress-circle--indeterminate">
<progress class="visually-hidden" aria-label="Loading report">Loading</progress>
<svg viewBox="0 0 36 36" aria-hidden="true" focusable="false">
<circle class="bootcn-progress-circle__track" cx="18" cy="18" r="15.9155" pathLength="100" />
<circle class="bootcn-progress-circle__value" cx="18" cy="18" r="15.9155" pathLength="100" />
</svg>
</div>
</div>css
.bootcn-progress-circle {
--bootcn-progress: 0;
--bootcn-progress-size: 3.5rem;
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
width: var(--bootcn-progress-size);
height: var(--bootcn-progress-size);
}
.bootcn-progress-circle--sm {
--bootcn-progress-size: 2.5rem;
}
.bootcn-progress-circle--lg {
--bootcn-progress-size: 5rem;
}
.bootcn-progress-circle svg {
width: 100%;
height: 100%;
transform: rotate(-90deg);
}
.bootcn-progress-circle circle {
fill: none;
stroke-width: 3.5;
}
.bootcn-progress-circle__track {
stroke: var(--bootcn-muted);
}
.bootcn-progress-circle__value {
stroke: var(--bootcn-primary);
stroke-linecap: round;
stroke-dasharray: var(--bootcn-progress) 100;
transition: stroke-dasharray var(--bootcn-transition);
}
.bootcn-progress-circle__label {
position: absolute;
font-size: calc(var(--bootcn-progress-size) * 0.24);
font-weight: 600;
font-variant-numeric: tabular-nums;
}
.bootcn-progress-circle--indeterminate .bootcn-progress-circle__value {
stroke-dasharray: 25 100;
}
.bootcn-progress-circle--indeterminate svg {
animation: bootcn-progress-circle-spin 1s linear infinite;
}
@keyframes bootcn-progress-circle-spin {
from {
transform: rotate(-90deg);
}
to {
transform: rotate(270deg);
}
}
@media (prefers-reduced-motion: reduce) {
.bootcn-progress-circle--indeterminate svg {
animation-duration: 3s;
}
}
