CSS loading animations
A loading animation tells people the app heard them. These are the patterns worth using, the CSS behind them and ready-made React components.
A simple CSS spinner
css
.spinner {
width: 20px; height: 20px;
border: 2px solid rgb(255 255 255 / .15);
border-top-color: #7dd3fc;
border-radius: 50%;
animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }Bouncing dots
css
.dots span {
display: inline-block; width: 6px; height: 6px; margin: 0 2px;
border-radius: 50%; background: currentColor;
animation: bounce 1s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4 } 40% { transform: translateY(-5px); opacity: 1 } }Shimmer skeletons
When a whole section is loading, a skeleton in the shape of the content feels faster than a spinner. Animate a gradient across a grey block:
css
.skeleton {
background: linear-gradient(90deg, #111 25%, #1c1c1c 50%, #111 75%);
background-size: 200% 100%;
animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }Which one to use
- Under a second: nothing, or a tiny spinner inside the button.
- One to ten seconds: a spinner or dots, ideally with a short status line.
- Page sections: skeletons.
- AI responses: a thinking indicator, then stream the answer.
Always add role="status" and visually hidden text such as "Loading…" so screen reader users get the same feedback.
Ready-made loading components
FAQ
How do I make a loading animation with CSS only?
Use a keyframe animation on transform or opacity, such as a rotating bordered circle or bouncing dots. No JavaScript is needed.
Are skeleton screens better than spinners?
For loading page sections, yes: they show the layout early and feel faster. Spinners suit short actions.
Keep reading
Website animation examplesWebsite animation examples you can copy: hero backgrounds, text effects, scroll reveals, hover states, cursors…The best React icon librariesA practical comparison of React icon libraries: Lucide, React Icons, Heroicons, Phosphor, Tabler, Radix Icons,…How to auto-resize a textareaMake a textarea grow with its content using CSS field-sizing, or a small React hook with scrollHeight. Plus ho…React frameworks comparedA clear guide to React frameworks: Next.js, React Router (formerly Remix), Astro, TanStack Start, Vite single-…