Stretch
React + Tailwind
const T = 1.4;
const R = 20;
const C = 2 * Math.PI * R;
// Both ends of the arc go round exactly once a cycle, but their speeds rise and
// fall half a cycle apart: the head leads while the tail slows, then the tail
// races while the head slows. The arc stretches and shrinks with no seam.
const A = 0.3;
const MIN = 0.05;
const N = 40;
const frames = Array.from({ length: N + 1 }, (_, i) => {
const u = i / N;
const g = (1 - Math.cos(2 * Math.PI * u)) / 2;
const tail = u - A * g;
const len = (MIN + 2 * A * g) * C;
return `${((u * 100).toFixed(2))}% { stroke-dasharray: ${len.toFixed(2)} ${(C - len).toFixed(2)}; stroke-dashoffset: ${(-tail * C).toFixed(2)}; }`;
}).join('\n ');
const css = `
.loader-stretch { --ink: light-dark(#373a40, #f1f2f3); --track: light-dark(#dbdde1, #2e3035); display: inline-block; font-size: 88px; width: 1em; height: 1em; }
.loader-stretch svg { display: block; width: 100%; height: 100%; rotate: -90deg; fill: none; stroke-width: 4; stroke-linecap: round; }
.loader-stretch__track { stroke: var(--track); }
.loader-stretch__arc { stroke: var(--ink); animation: loader-stretch-arc ${T}s linear infinite; }
@keyframes loader-stretch-arc {
${frames}
}
@media (prefers-reduced-motion: reduce) {
.loader-stretch__arc { animation: none; stroke-dasharray: ${(0.3 * C).toFixed(2)} ${(0.7 * C).toFixed(2)}; }
}
`;
export function Preview() {
return (
<>
<style href="kit-loaders-stretch" precedence="kit">
{css}
</style>
<div className="loader-stretch" role="status" aria-label="Loading">
<svg viewBox="0 0 50 50" aria-hidden="true">
<circle className="loader-stretch__track" cx="25" cy="25" r={R} />
<circle className="loader-stretch__arc" cx="25" cy="25" r={R} />
</svg>
</div>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
HTML
<div class="loader-stretch" role="status" aria-label="Loading">
<svg viewBox="0 0 50 50" aria-hidden="true">
<circle class="loader-stretch__track" cx="25" cy="25" r="20"></circle>
<circle class="loader-stretch__arc" cx="25" cy="25" r="20"></circle>
</svg>
</div>CSS
.loader-stretch { --ink: light-dark(#373a40, #f1f2f3); --track: light-dark(#dbdde1, #2e3035); display: inline-block; font-size: 88px; width: 1em; height: 1em; }
.loader-stretch svg { display: block; width: 100%; height: 100%; rotate: -90deg; fill: none; stroke-width: 4; stroke-linecap: round; }
.loader-stretch__track { stroke: var(--track); }
.loader-stretch__arc { stroke: var(--ink); animation: loader-stretch-arc 1.4s linear infinite; }
@keyframes loader-stretch-arc {
0.00% { stroke-dasharray: 6.28 119.38; stroke-dashoffset: 0.00; }
2.50% { stroke-dasharray: 6.75 118.92; stroke-dashoffset: -2.91; }
5.00% { stroke-dasharray: 8.13 117.54; stroke-dashoffset: -5.36; }
7.50% { stroke-dasharray: 10.39 115.27; stroke-dashoffset: -7.37; }
10.00% { stroke-dasharray: 13.48 112.18; stroke-dashoffset: -8.97; }
12.50% { stroke-dasharray: 17.32 108.34; stroke-dashoffset: -10.19; }
15.00% { stroke-dasharray: 21.82 103.84; stroke-dashoffset: -11.08; }
17.50% { stroke-dasharray: 26.87 98.80; stroke-dashoffset: -11.70; }
20.00% { stroke-dasharray: 32.33 93.33; stroke-dashoffset: -12.11; }
22.50% { stroke-dasharray: 38.08 87.58; stroke-dashoffset: -12.37; }
25.00% { stroke-dasharray: 43.98 81.68; stroke-dashoffset: -12.57; }
27.50% { stroke-dasharray: 49.88 75.78; stroke-dashoffset: -12.76; }
30.00% { stroke-dasharray: 55.63 70.03; stroke-dashoffset: -13.02; }
32.50% { stroke-dasharray: 61.10 64.57; stroke-dashoffset: -13.43; }
35.00% { stroke-dasharray: 66.14 59.52; stroke-dashoffset: -14.05; }
37.50% { stroke-dasharray: 70.64 55.02; stroke-dashoffset: -14.95; }
40.00% { stroke-dasharray: 74.48 51.18; stroke-dashoffset: -16.17; }
42.50% { stroke-dasharray: 77.57 48.09; stroke-dashoffset: -17.76; }
45.00% { stroke-dasharray: 79.84 45.83; stroke-dashoffset: -19.77; }
47.50% { stroke-dasharray: 81.22 44.45; stroke-dashoffset: -22.22; }
50.00% { stroke-dasharray: 81.68 43.98; stroke-dashoffset: -25.13; }
52.50% { stroke-dasharray: 81.22 44.45; stroke-dashoffset: -28.51; }
55.00% { stroke-dasharray: 79.84 45.83; stroke-dashoffset: -32.34; }
57.50% { stroke-dasharray: 77.57 48.09; stroke-dashoffset: -36.61; }
60.00% { stroke-dasharray: 74.48 51.18; stroke-dashoffset: -41.30; }
62.50% { stroke-dasharray: 70.64 55.02; stroke-dashoffset: -46.36; }
65.00% { stroke-dasharray: 66.14 59.52; stroke-dashoffset: -51.75; }
67.50% { stroke-dasharray: 61.10 64.57; stroke-dashoffset: -57.42; }
70.00% { stroke-dasharray: 55.63 70.03; stroke-dashoffset: -63.29; }
72.50% { stroke-dasharray: 49.88 75.78; stroke-dashoffset: -69.31; }
75.00% { stroke-dasharray: 43.98 81.68; stroke-dashoffset: -75.40; }
77.50% { stroke-dasharray: 38.08 87.58; stroke-dashoffset: -81.49; }
80.00% { stroke-dasharray: 32.33 93.33; stroke-dashoffset: -87.51; }
82.50% { stroke-dasharray: 26.87 98.80; stroke-dashoffset: -93.38; }
85.00% { stroke-dasharray: 21.82 103.84; stroke-dashoffset: -99.04; }
87.50% { stroke-dasharray: 17.32 108.34; stroke-dashoffset: -104.43; }
90.00% { stroke-dasharray: 13.48 112.18; stroke-dashoffset: -109.50; }
92.50% { stroke-dasharray: 10.39 115.27; stroke-dashoffset: -114.18; }
95.00% { stroke-dasharray: 8.13 117.54; stroke-dashoffset: -118.46; }
97.50% { stroke-dasharray: 6.75 118.92; stroke-dashoffset: -122.29; }
100.00% { stroke-dasharray: 6.28 119.38; stroke-dashoffset: -125.66; }
}
@media (prefers-reduced-motion: reduce) {
.loader-stretch__arc { animation: none; stroke-dasharray: 37.70 87.96; }
}Goal: Create a "Stretch" loader.
Visual behavior: A single arc runs round a faint ring, stretching while its head pulls ahead and shrinking while its tail catches up.
Technique:
- Pure CSS: every motion is a keyframe animation, so the plain HTML version needs no script.
- Everything is sized in em from one font-size on the root, so changing that one value scales the whole loader.
- Both ends of the arc go round exactly once a cycle, but their speeds rise and fall half a cycle apart, so the arc grows while the head leads and shrinks while the tail catches up.
- The dash is set as the arc length and the rest of the circle, so the pattern repeats once per circle and the loop has no seam where it starts again.
- The keyframes are sampled from those two speed curves, so neither end ever stops or jumps.
Accessibility: The root has role="status" and aria-label="Loading"; everything inside it is aria-hidden. Under prefers-reduced-motion the arc rests at a third of the ring.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: neutral only. Black, white and grays, no hues. Use the color values above as written, or my project's closest neutral tokens.
Return a single self-contained component. No dependencies.Goal: Create a "Stretch" loader.
Visual behavior: A single arc runs round a faint ring, stretching while its head pulls ahead and shrinking while its tail catches up.
Technique:
- Pure CSS: every motion is a keyframe animation, so the plain HTML version needs no script.
- Everything is sized in em from one font-size on the root, so changing that one value scales the whole loader.
- Both ends of the arc go round exactly once a cycle, but their speeds rise and fall half a cycle apart, so the arc grows while the head leads and shrinks while the tail catches up.
- The dash is set as the arc length and the rest of the circle, so the pattern repeats once per circle and the loop has no seam where it starts again.
- The keyframes are sampled from those two speed curves, so neither end ever stops or jumps.
Accessibility: The root has role="status" and aria-label="Loading"; everything inside it is aria-hidden. Under prefers-reduced-motion the arc rests at a third of the ring.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: use my project's existing color tokens. The color values above are grayscale placeholders. Map each one by its role (surface, text, border, accent, glow) to my theme, and keep their relative lightness so contrast and the effect still read.
Return a single self-contained component. No dependencies.Paste into Claude, ChatGPT or Cursor after filling in {{USER_STACK}}, {{USER_STYLING}} and {{USER_CONSTRAINTS}}. Neutral keeps the greys you see here; Match my project asks the model to map them onto your own colour tokens.
Free to use in any project, commercial included. MIT-0, no attribution required. Licence
About this component
A single arc runs round a faint ring, stretching while its head pulls ahead and shrinking while its tail catches up.
- Dependencies
- None
- Difficulty
- Intermediate
- Triggers
- continuous, loop, draw
- Techniques
- svg, stroke dashoffset, keyframes
- Reduced motion
- Respected
- Theme
- Light and dark (follows your page's color-scheme)
The root has role="status" and aria-label="Loading"; everything inside it is aria-hidden. Under prefers-reduced-motion the arc rests at a third of the ring.