Fractal
React + Tailwind
const css = `
@keyframes loader-fractal-cell {
0% { opacity: 0.12; }
10% { opacity: 1; }
45% { opacity: 1; }
65%, 100% { opacity: 0.12; }
}
.loader-fractal { display: block; width: 96px; height: 84px; }
.loader-fractal__cell {
fill: light-dark(#373a40, #f1f2f3);
opacity: 0.12;
animation: loader-fractal-cell 2.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
.loader-fractal__cell { animation: none; opacity: 0.7; }
}
`;
type P = [number, number];
/** The Sierpinski triangle to `depth`, as its smallest triangles in recursive (corner-first) order. */
function sierpinski(a: P, b: P, c: P, depth: number): P[][] {
if (depth === 0) return [[a, b, c]];
const mid = (p: P, q: P): P => [(p[0] + q[0]) / 2, (p[1] + q[1]) / 2];
const ab = mid(a, b);
const bc = mid(b, c);
const ca = mid(c, a);
return [...sierpinski(a, ab, ca, depth - 1), ...sierpinski(ab, b, bc, depth - 1), ...sierpinski(ca, bc, c, depth - 1)];
}
const H = 96 * (Math.sqrt(3) / 2);
// Shrink each cell toward its own centre so the recursion's gaps read clearly.
const CELLS = sierpinski([48, 0], [0, H], [96, H], 3).map((t) => {
const cx = (t[0][0] + t[1][0] + t[2][0]) / 3;
const cy = (t[0][1] + t[1][1] + t[2][1]) / 3;
return t.map(([x, y]) => `${(cx + (x - cx) * 0.82).toFixed(2)},${(cy + (y - cy) * 0.82).toFixed(2)}`).join(' ');
});
export function FractalLoader() {
return (
<>
<style>
{css}
</style>
<svg className="loader-fractal" viewBox={`0 0 96 ${H.toFixed(2)}`} role="status" aria-label="Loading">
{CELLS.map((pts, i) => (
<polygon key={i} className="loader-fractal__cell" points={pts} style={{ animationDelay: `${(i * 0.05).toFixed(2)}s` }} />
))}
</svg>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
HTML
<svg class="loader-fractal" viewBox="0 0 96 83.14" role="status" aria-label="Loading">
<polygon class="loader-fractal__cell" points="48.00,1.25 43.08,9.77 52.92,9.77" style="animation-delay:0.00s"></polygon>
<polygon class="loader-fractal__cell" points="42.00,11.64 37.08,20.16 46.92,20.16" style="animation-delay:0.05s"></polygon>
<polygon class="loader-fractal__cell" points="54.00,11.64 49.08,20.16 58.92,20.16" style="animation-delay:0.10s"></polygon>
<polygon class="loader-fractal__cell" points="36.00,22.03 31.08,30.55 40.92,30.55" style="animation-delay:0.15s"></polygon>
<polygon class="loader-fractal__cell" points="30.00,32.42 25.08,40.95 34.92,40.95" style="animation-delay:0.20s"></polygon>
<polygon class="loader-fractal__cell" points="42.00,32.42 37.08,40.95 46.92,40.95" style="animation-delay:0.25s"></polygon>
<polygon class="loader-fractal__cell" points="60.00,22.03 55.08,30.55 64.92,30.55" style="animation-delay:0.30s"></polygon>
<polygon class="loader-fractal__cell" points="54.00,32.42 49.08,40.95 58.92,40.95" style="animation-delay:0.35s"></polygon>
<polygon class="loader-fractal__cell" points="66.00,32.42 61.08,40.95 70.92,40.95" style="animation-delay:0.40s"></polygon>
<polygon class="loader-fractal__cell" points="24.00,42.82 19.08,51.34 28.92,51.34" style="animation-delay:0.45s"></polygon>
<polygon class="loader-fractal__cell" points="18.00,53.21 13.08,61.73 22.92,61.73" style="animation-delay:0.50s"></polygon>
<polygon class="loader-fractal__cell" points="30.00,53.21 25.08,61.73 34.92,61.73" style="animation-delay:0.55s"></polygon>
<polygon class="loader-fractal__cell" points="12.00,63.60 7.08,72.12 16.92,72.12" style="animation-delay:0.60s"></polygon>
<polygon class="loader-fractal__cell" points="6.00,73.99 1.08,82.51 10.92,82.51" style="animation-delay:0.65s"></polygon>
<polygon class="loader-fractal__cell" points="18.00,73.99 13.08,82.51 22.92,82.51" style="animation-delay:0.70s"></polygon>
<polygon class="loader-fractal__cell" points="36.00,63.60 31.08,72.12 40.92,72.12" style="animation-delay:0.75s"></polygon>
<polygon class="loader-fractal__cell" points="30.00,73.99 25.08,82.51 34.92,82.51" style="animation-delay:0.80s"></polygon>
<polygon class="loader-fractal__cell" points="42.00,73.99 37.08,82.51 46.92,82.51" style="animation-delay:0.85s"></polygon>
<polygon class="loader-fractal__cell" points="72.00,42.82 67.08,51.34 76.92,51.34" style="animation-delay:0.90s"></polygon>
<polygon class="loader-fractal__cell" points="66.00,53.21 61.08,61.73 70.92,61.73" style="animation-delay:0.95s"></polygon>
<polygon class="loader-fractal__cell" points="78.00,53.21 73.08,61.73 82.92,61.73" style="animation-delay:1.00s"></polygon>
<polygon class="loader-fractal__cell" points="60.00,63.60 55.08,72.12 64.92,72.12" style="animation-delay:1.05s"></polygon>
<polygon class="loader-fractal__cell" points="54.00,73.99 49.08,82.51 58.92,82.51" style="animation-delay:1.10s"></polygon>
<polygon class="loader-fractal__cell" points="66.00,73.99 61.08,82.51 70.92,82.51" style="animation-delay:1.15s"></polygon>
<polygon class="loader-fractal__cell" points="84.00,63.60 79.08,72.12 88.92,72.12" style="animation-delay:1.20s"></polygon>
<polygon class="loader-fractal__cell" points="78.00,73.99 73.08,82.51 82.92,82.51" style="animation-delay:1.25s"></polygon>
<polygon class="loader-fractal__cell" points="90.00,73.99 85.08,82.51 94.92,82.51" style="animation-delay:1.30s"></polygon>
</svg>CSS
@keyframes loader-fractal-cell {
0% { opacity: 0.12; }
10% { opacity: 1; }
45% { opacity: 1; }
65%, 100% { opacity: 0.12; }
}
.loader-fractal { display: block; width: 96px; height: 84px; }
.loader-fractal__cell {
fill: light-dark(#373a40, #f1f2f3);
opacity: 0.12;
animation: loader-fractal-cell 2.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
.loader-fractal__cell { animation: none; opacity: 0.7; }
}Goal: Create a "Fractal" loader.
Visual behavior: A Sierpinski triangle of 27 cells that light up in a wave running through the recursion order, corner by corner, then dim back down, over and over.
Technique:
- A recursive function splits a triangle into its three corner triangles three levels deep, giving the 27 smallest cells in recursive (corner-first) order.
- Each cell is shrunk slightly toward its own centre so the gaps of the fractal read clearly, and drawn as an SVG polygon.
- All cells share a 2.4s opacity keyframe (dim, flash bright, hold, dim) with a 0.05s delay per cell in that recursive order, so the light moves through the fractal's structure.
Accessibility: The root has role="status" and aria-label="Loading"; everything inside is decorative. Under prefers-reduced-motion every cell shows at steady opacity.
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 "Fractal" loader.
Visual behavior: A Sierpinski triangle of 27 cells that light up in a wave running through the recursion order, corner by corner, then dim back down, over and over.
Technique:
- A recursive function splits a triangle into its three corner triangles three levels deep, giving the 27 smallest cells in recursive (corner-first) order.
- Each cell is shrunk slightly toward its own centre so the gaps of the fractal read clearly, and drawn as an SVG polygon.
- All cells share a 2.4s opacity keyframe (dim, flash bright, hold, dim) with a 0.05s delay per cell in that recursive order, so the light moves through the fractal's structure.
Accessibility: The root has role="status" and aria-label="Loading"; everything inside is decorative. Under prefers-reduced-motion every cell shows at steady opacity.
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 Sierpinski triangle of 27 cells that light up in a wave running through the recursion order, corner by corner, then dim back down, over and over.
- Dependencies
- None
- Difficulty
- Beginner
- Triggers
- continuous, loop, delay stagger
- Techniques
- svg, keyframes, stagger
- Reduced motion
- Respected
- Theme
- Light and dark (follows your page's color-scheme)
The root has role="status" and aria-label="Loading"; everything inside is decorative. Under prefers-reduced-motion every cell shows at steady opacity.