AI CSS Animations

Squircle Spinner

A dash stretches and snaps along a rounded square track instead of a circle. It suits app icons, avatars and square thumbnails, and the SVG rect uses pathLength to keep the dash math simple.

Also known as: rounded square spinner, square border loading animation, app icon loader.

HTML

<svg class="ldr-squircle-spinner" viewBox="0 0 48 48" role="status" aria-label="Loading">
  <rect class="ldr-squircle-spinner-track" x="5" y="5" width="38" height="38" rx="14" pathLength="100"></rect>
  <rect class="ldr-squircle-spinner-run" x="5" y="5" width="38" height="38" rx="14" pathLength="100"></rect>
</svg>

CSS

.ldr-squircle-spinner {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  width: var(--s);
  height: var(--s);
}
.ldr-squircle-spinner rect {
  fill: none;
  stroke-width: 4.5;
  stroke-linecap: round;
}
.ldr-squircle-spinner-track {
  stroke: color-mix(in srgb, var(--ldr-color, #3b82f6) 18%, transparent);
}
.ldr-squircle-spinner-run {
  stroke: var(--c);
  animation: ldr-squircle-spinner-run 1.6s cubic-bezier(0.45, 0, 0.25, 1) infinite;
}
@keyframes ldr-squircle-spinner-run {
  0%   { stroke-dasharray: 8 92;  stroke-dashoffset: 0; }
  50%  { stroke-dasharray: 45 55; stroke-dashoffset: -10; }
  100% { stroke-dasharray: 8 92;  stroke-dashoffset: -100; }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-squircle-spinner, .ldr-squircle-spinner *, .ldr-squircle-spinner::before, .ldr-squircle-spinner::after, .ldr-squircle-spinner *::before, .ldr-squircle-spinner *::after {
    animation-duration: 3s;
  }
}

Customizing this loader

  • Color: set --ldr-color on the element or a parent. Currently previewing #3b82f6.
  • Size: set --ldr-size. Every dimension in the snippet is derived from it. Currently previewing 64px.
  • Speed: change the duration on the animation shorthand. Delays on the children are relative, so they keep their rhythm.
  • Accessibility: the root carries role="status" and an aria-label so screen readers announce the wait. The reduced-motion rule at the end slows the animation for users who asked for less motion.

Similar loaders