# Dot Swap Loader

> Two colored dots that circle around each other and trade places, passing in front and behind.

- Category: [CSS Loaders & Spinners](https://copy-css.com/category/loaders)
- Tags: dots, orbit, two colors, trade places, z-index
- Live preview: https://copy-css.com/snippets/dot-swap-loader
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="loader-swap" role="status" aria-label="Loading"></div>
```

## CSS

```css
.loader-swap {
  position: relative;
  width: 44px;
  height: 16px;
}

.loader-swap::before,
.loader-swap::after {
  content: "";
  position: absolute;
  top: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  animation: 1.1s ease-in-out infinite;
}

.loader-swap::before {
  left: 0;
  background: #f43f5e;
  animation-name: loader-swap-a;
}

.loader-swap::after {
  right: 0;
  z-index: 1;
  background: #06b6d4;
  animation-name: loader-swap-b;
}

@keyframes loader-swap-a {
  0% { transform: translateX(0); z-index: 2; }
  25% { transform: translateX(14px) scale(1.3); z-index: 2; }
  49% { z-index: 2; }
  50% { transform: translateX(28px); z-index: 0; }
  75% { transform: translateX(14px) scale(0.7); z-index: 0; }
  100% { transform: translateX(0); z-index: 0; }
}

@keyframes loader-swap-b {
  0% { transform: translateX(0); }
  25% { transform: translateX(-14px) scale(0.7); }
  50% { transform: translateX(-28px); }
  75% { transform: translateX(-14px) scale(1.3); }
  100% { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .loader-swap::before,
  .loader-swap::after { animation-duration: 3s; }
}
```

## Notes

- This CSS Dot Swap Loader is 51 lines of pure CSS (1.1 KB) with no JavaScript and no dependencies. It uses keyframe animations, transforms and reduced-motion support.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
