CSS Loader Generator
A spinner tells your users that something is happening. This generator builds one circular CSS spinner: set the diameter, the border thickness, the accent color and the rotation speed, watch the live preview, then copy the CSS. Everything is plain CSS, no SVG, no JavaScript and no external libraries.
How to use the generator
-
1
Set the size
Diameter of the spinner in pixels. 40-80 px fits most buttons and content areas.
-
2
Set the border thickness
The ring is a border drawn on a circle. A thicker border makes a bolder arc; 4-8 px reads well at 60 px.
-
3
Choose the color
The accent color of the spinning arc. The rest of the ring stays a light gray so the arc stands out.
-
4
Set the speed and copy the CSS
Rotation time in seconds per full turn. Around 1 second is the common sweet spot; below 500 ms feels frantic, above 2 s feels sluggish.
How the generated CSS works
.loader {
width: 60px;
height: 60px;
border: 6px solid #eee;
border-top-color: #10b981;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
The loader is a circle drawn with a thick border. The border-top-color rule paints only the top of the ring with the accent color, so the ring reads as an arc, and the @keyframes spin rule rotates it around its center. Rotating with transform: rotate() keeps the animation cheap, because the browser moves the element on the compositor instead of redrawing it frame by frame.
To show it on a page, add one element and load the CSS:
<div class="loader" role="status" aria-label="Loading"></div>
Make it accessible
- Add
role="status"so screen readers announce the loader. - Set
aria-labelto the status text, for example “Loading”. - Do not hide content behind a loader for more than a few seconds without a timeout fallback.
- Respect
prefers-reduced-motion. Replace the spinning animation with a simple fade or a static “Loading…” text for users who opted out:
@media (prefers-reduced-motion: reduce) {
.loader { animation: none; background: currentColor; opacity: .4; }
}
When to use a loader vs. optimistic UI
- < 100ms response: no loader needed; the human eye barely perceives the delay.
- 100ms – 1s: a subtle loader (small spinner, button text “Loading…”) prevents double-clicks.
- 1s – 10s: a prominent loader, ideally with progress if measurable.
- > 10s: not a spinner problem, find out what is slow and fix it.
For form submits and button clicks, an in-button spinner is usually better than a full-page overlay.
Frequently Asked Questions
CSS for simple single-element spinners (the four-border rotate trick). SVG when you need a tapered trail, multiple stroke dasharray animations, or filled segments that look like paint strokes. CSS is smaller and simpler; SVG is more flexible.
Probably because you are rotating a large element or animating a non-composited property. Keep spinner size small, use transform: rotate() (not top/margin), and avoid triggering it while other heavy animations run.
Almost universally clockwise. Counter-clockwise spinners feel subtly wrong because most real rotation cues (clocks, windmills) go clockwise. Stick with convention unless you have a specific reason.
With a setTimeout(..., 300) in JavaScript that adds the loader class, plus a clearTimeout if the operation finishes first. Prevents flicker on fast responses without hiding real delays.
Related Tools
ASCII Table Reference
Full ASCII table from 0 to 127 with decimal, hex, octal, binary, standard names and HTML numeric-reference notation, including NUL, LF and DEL.
HEX Color Picker
Pick or enter a HEX colour and get RGB, HSL, approximate CMYK, relative luminance and contrast ratios against white and black.
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
HTML Character Reference
Searchable list of HTML entities, their named and numeric codes, and a one-click copy for special characters and symbols.
FPS Counter
Measure browser FPS with requestAnimationFrame, smoothing, min/max frame rate, warnings and an optional graph. Runs locally with no upload or API.
JSON Formatter
Paste JSON to pretty-print with 2 or 4 spaces, minify it to compact output, or run a quick syntax check before copying the result.