An arc chases itself around the box, stretching out and snapping short like the Material spinner, for boxes that are busy but have no progress to show. Dash length and offset share one keyframe.
Also known as: css border loading animation, border spinner css, indeterminate border progress.
<div class="bdr-loading-border">
<svg class="bdr-loading-border-svg" aria-hidden="true">
<rect class="bdr-loading-border-track" width="100%" height="100%"/>
<rect class="bdr-loading-border-arc" width="100%" height="100%" pathLength="100"/>
</svg>
Uploading
</div>.bdr-loading-border {
--c: var(--bdr-color, #3b82f6);
font-size: var(--bdr-size, 16px);
position: relative;
display: grid;
place-items: center;
width: 15em;
height: 8.5em;
border-radius: 1em;
font-family: system-ui, sans-serif;
font-weight: 600;
background: color-mix(in srgb, var(--c) 5%, transparent);
}
.bdr-loading-border-svg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
.bdr-loading-border-svg rect {
rx: 1em;
fill: none;
stroke-width: 0.16em;
}
.bdr-loading-border-track { stroke: color-mix(in srgb, var(--c) 15%, transparent); }
.bdr-loading-border-arc {
stroke: var(--c);
stroke-linecap: round;
animation: bdr-loading-border-chase 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes bdr-loading-border-chase {
0% { stroke-dasharray: 1 99; stroke-dashoffset: 0; }
50% { stroke-dasharray: 42 58; stroke-dashoffset: -8; }
100% { stroke-dasharray: 1 99; stroke-dashoffset: -99; }
}
@media (prefers-reduced-motion: reduce) {
.bdr-loading-border, .bdr-loading-border *, .bdr-loading-border::before, .bdr-loading-border::after, .bdr-loading-border *::before, .bdr-loading-border *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--bdr-color on the element or a parent.
Currently previewing #3b82f6.--bdr-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.