Twist

No dependencies
Code format
React + Tailwind
import type { CSSProperties } from 'react';

const T = 1.9;
const SQUARES = 5;

const css = `
  .loader-twist { --ink: light-dark(#373a40, #f1f2f3); display: inline-grid; place-items: center; font-size: 88px; width: 1em; height: 1em; }
  /* Each square waits a beat longer than the one outside it, so the quarter turn winds inward. */
  .loader-twist__square { grid-area: 1 / 1; width: var(--s); height: var(--s); box-sizing: border-box; border: 0.045em solid var(--ink); border-radius: 22%; opacity: var(--o); animation: loader-twist-turn ${T}s infinite; animation-delay: var(--d); }
  @keyframes loader-twist-turn {
    0% { transform: rotate(0deg); animation-timing-function: cubic-bezier(0.7, 0, 0.3, 1); }
    52%, 100% { transform: rotate(90deg); }
  }
  @media (prefers-reduced-motion: reduce) {
    .loader-twist__square { animation: none; transform: rotate(calc(var(--i) * 9deg)); }
  }
`;

export function Preview() {
  return (
    <>
      <style href="kit-loaders-twist" precedence="kit">
        {css}
      </style>
      <div className="loader-twist" role="status" aria-label="Loading">
        {Array.from({ length: SQUARES }, (_, i) => (
          <span
            key={i}
            className="loader-twist__square"
            style={{ '--s': `${(1 - i * 0.19).toFixed(2)}em`, '--o': (1 - i * 0.16).toFixed(2), '--d': `${(i * 0.075).toFixed(3)}s`, '--i': i } as CSSProperties}
            aria-hidden="true"
          />
        ))}
      </div>
    </>
  );
}

Free to use in any project, commercial included. MIT-0, no attribution required. Licence

Install with shadcn

npx shadcn@latest add @movin/loader-twist
Source on GitHub

About this component

Five nested squares turn a quarter one after another, so the stack winds into a spiral and straightens out again.

Dependencies
None
Difficulty
Beginner
Triggers
continuous, loop, delay stagger
Techniques
keyframes, transition delay stagger, transform only
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 squares rest slightly turned against each other, as a still spiral.

More loaders

See all
Typewriter
Worm
Abacus
Barber pole