When a dashboard button waits half a second on an API response, a good loading indicator tells the user "we heard your click" without dragging extra runtime JS or animated GIF assets onto the page. Two tiny CSS patterns cover 90% of real apps: a crisp dual-tone ring spinner for buttons, and a low-contrast skeleton placeholder for cards so the page never jumps when data settles (protecting CLS too).
1. Zero-Shift Button Ring Spinner
.btn-spinner {
width: 18px;
height: 18px;
border: 2.5px solid rgba(79, 70, 229, 0.22);
border-top-color: #4f46e5;
border-radius: 50%;
animation: spin 0.7s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
2. Lightweight Skeleton Card Placeholder
For initial page cards, spinners actually feel slower than gray skeleton boxes matching the real height of your text and thumbnails. Keep layout heights locked and test timing curves in our Animation Previewer, CSS Keyframe Builder, or convert classes straight into utilities with our CSS to Tailwind Converter.
.skeleton-line {
height: 14px;
border-radius: 6px;
background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
background-size: 200% 100%;
animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
Frequently Asked Questions
Do spinners hurt Cumulative Layout Shift (CLS)?
Only if they replace an empty 0px box and push text down when injected. Give buttons a fixed minimum height and width before toggling the loading state.
How do I announce loading states to screen readers?
Add role="status" or aria-busy="true" on the container and include visually hidden status text like "Loading results".