Performance: Spin animation (loading)
Spin animations affect the browser's paint and composite stages, impacting smoothness and interaction responsiveness.
<svg class="animate-spin w-12 h-12 text-blue-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" stroke-opacity="0.25"/><path d="M4 12a8 8 0 018-8"/></svg>
<div class="animate-spin border-4 border-blue-500 border-t-transparent rounded-full w-12 h-12"></div>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Border-based spin animation | Minimal (1 element) | 0 | High (continuous repaint) | [X] Bad |
| SVG spin animation | Minimal (1 element) | 0 | Low (mostly compositing) | [OK] Good |
animate-spin do to an element?animate-spinanimate-spin class in Tailwind applies a continuous rotation animation to the element.animate-spin does.animate-spin = continuous rotation [OK]animate-spin, so options A, B, and C use incorrect or non-existent classes.<div class='border-4 border-blue-500 animate-spin rounded-full'></div> correctly uses border-4 for thickness, border-blue-500 for color, and rounded-full for a circle shape.<div class='border-4 border-blue-500 animate-spin rounded-full'></div> [OK]animate-spin for spinning [OK]rounded-full for circle shape<div class='w-12 h-12 border-4 border-gray-300 border-t-blue-600 animate-spin rounded-full'></div>
w-12 and h-12 set width and height to 3rem (48px). rounded-full makes it a circle.border-4 sets border thickness. border-gray-300 colors all borders gray except border-t-blue-600 which colors top border blue. animate-spin makes it spin continuously.<div class='border-4 border-blue-500 rounded-full spin'></div>
spin does not exist in Tailwind. The correct class for spinning is animate-spin.border-4 and rounded-full do not affect animation. Missing border-t-transparent affects spinner style but not rotation.spin is not a valid Tailwind animation class -> Option Aanimate-spin for rotation [OK]animate-spin for spinning [OK]spin instead of animate-spinrole='status' and aria-live='polite' tells screen readers to announce changes politely.sr-only class hides text visually but keeps it readable by screen readers, perfect for "Loading..." message.role='status' + sr-only for accessible loading [OK]sr-only for hidden accessible text [OK]sr-only hides text visually and accessiblyPass the test and this pattern moves unknown