Array Rotation Loader
Create an “array rotation” loading animation using HTML, TailwindCSS, and CSS.
Demo
Loading...
Code
1<div>2 <div class="loader relative flex gap-[8px] translate-x-[-9px]">3 <span class="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span>4 <span class="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span>5 <span class="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span>6 <span class="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span>7 <span class="block w-[10px] h-[10px] bg-current rounded-full animate-[jump_1s_ease_infinite]"></span>8 </div>9 <div class="">Loading...</div>10</div>11
12<style>13 @keyframes move {14 0% {15 transform: translateX(0);16 }17 100% {18 transform: translateX(19px);19 }20 }21
22 @keyframes jump {23 0% {24 transform: translate(0, 0);25 }26 30% {27 transform: translate(0px, -30px);28 }29 70% {30 transform: translate(-72px, -30px);31 }32 100% {33 transform: translate(-72px, 0px);34 }35 }36</style>Prerequisites
TailwindCSS is required to use the code snippet above.
Steps
-
Create an
htmlskeleton as follows:<div><div class="loader relative flex gap-[8px] translate-x-[-9px]"><!-- Each span represents a dot --><span class="block w-[10px] h-[10px] bg-current rounded-full"></span><span class="block w-[10px] h-[10px] bg-current rounded-full"></span><span class="block w-[10px] h-[10px] bg-current rounded-full"></span><span class="block w-[10px] h-[10px] bg-current rounded-full"></span><span class="block w-[10px] h-[10px] bg-current rounded-full"></span></div><div class="">Loading...</div></div> -
Create the following keyframes to animate the dots:
@keyframes move {0% {transform: translateX(0);}100% {transform: translateX(19px);}}@keyframes jump {0% {transform: translate(0, 0);}30% {transform: translate(0px, -30px);}70% {transform: translate(-72px, -30px);}100% {transform: translate(-72px, 0px);}}movekeyframes will move a dot to the right, andjumpkeyframes will make a dot jump to the front. -
Add the animation to the dots:
<!-- Each span represents a dot --><spanclass="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span><spanclass="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span><spanclass="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span><spanclass="block w-[10px] h-[10px] bg-current rounded-full animate-[move_1s_linear_infinite]"></span><spanclass="block w-[10px] h-[10px] bg-current rounded-full animate-[jump_1s_ease_infinite]"></span>Please note that the first four dots will have the
moveanimation with a linear timing function, and the last dot will have thejumpanimation with an ease timing function. -
You should now have a “array rotation” loading animation.