How to use this CSS loader generator
Choose one of the three styles first. The spinner is the safe all-rounder: a ring with one coloured segment that rotates once per cycle. The dots bounce in sequence and feel light and friendly. The bars stretch up and down in a wave, which suits dashboards and tools. Then set the colour — your brand colour is the obvious choice — and the size, which is the width of the whole animation in pixels. The speed is the length of one full cycle in seconds; the default of one second is calm and clear. Everything updates the preview instantly, and the CSS and HTML boxes below always hold the matching code, ready to copy.
On your own site, the loader is two pieces: the CSS goes in your stylesheet, the HTML goes where the loader should appear. Show it while content loads and hide it afterwards with one line of JavaScript. Because the loader is pure CSS, it starts animating immediately, even before your JavaScript files have loaded — exactly when a loader matters most.
Example: the default spinner
With the default settings (spinner style, #2563eb, 48px, 1 second), the generator produces this CSS:
and this HTML:
The trick in the spinner is simple once you see it: a circle with a light grey border all the way round, one coloured border segment on top, and an animation that rotates the whole circle. The border width (6px here) is calculated from the size you choose, so the ring stays in proportion if you make the loader bigger or smaller.
Why pure CSS beats an animated GIF
A loading GIF is an image file: it has to be downloaded, it is fixed at the size and colour it was made, and it often looks soft on modern high-resolution screens. The CSS loader on this page is a few hundred bytes of text, downloads nothing, renders crisply at any size, and changes colour by editing a single value. It also respects the visitor's connection — on a slow network, an image loader can itself arrive late, which defeats the entire point. CSS is already there, so the animation starts the moment the element is on the page.
Performance and politeness
All three animations here move only transform and opacity. Browsers can run those on the graphics processor, so the animation stays smooth even while the main thread is busy — which, during a loading wait, it usually is. Two courtesies are worth adding on your site. First, keep waits honest: if something regularly takes more than a few seconds, add a short caption under the loader saying what is happening. Second, consider visitors who prefer reduced motion: a short media query for prefers-reduced-motion can slow or still the animation for them. Neither changes the generated code's structure — they are small additions around it.
Where a loader belongs — and where it does not
A loader is a promise that something is coming, so it should only appear when something genuinely is. Good places: a results area waiting for data, a button that just submitted a form, a dashboard panel fetching fresh numbers, or an image gallery loading its next set. Bad places: on every page navigation of a fast site, where it flashes for a tenth of a second and teaches visitors to distrust it, or as a permanent decoration, where it stops meaning anything at all. A useful rule is to show a loader only when the wait passes roughly half a second, and to remove it the moment real content exists — even partial content. Skeleton screens, the grey placeholder shapes some apps use, are the natural next step when a layout is predictable: they show the shape of what is coming instead of a symbol. Until then, an honest spinner, correctly coloured and correctly sized, remains the clearest signal on the web that a page is working on it.
Frequently asked questions
How do I add the loader to my website?
Paste the CSS into your stylesheet and the HTML where the loader should appear. Show the loader while your content or data is loading, then hide it with JavaScript (for example by setting its display to none) or remove it from the page once the content is ready.
Why use a CSS loader instead of a GIF or video?
A pure CSS loader is a few hundred bytes of text, needs no image file or extra request, stays perfectly sharp at any size, and can be recoloured by changing one value. An animated GIF for the same job is often tens of kilobytes, fixed in size and colour, and looks fuzzy on high-resolution screens.
Which loader style should I choose?
The spinner suits short waits almost anywhere and is the most widely recognised. Bouncing dots feel friendly and work well in chat-style or content feeds. Stretching bars read as more energetic and technical, a good fit for dashboards and media tools. Pick the one that matches your site's tone, and keep it consistent everywhere.
How fast should the animation be?
One second per cycle is a calm, professional default. Much faster feels frantic and can annoy people during a long wait; much slower looks broken, as if the page has frozen. If a wait regularly exceeds a few seconds, pair the loader with a short line of text explaining what is happening.
Can I centre the loader on the screen?
Yes. Wrap it in a container with display: flex, align-items: center and justify-content: center, and give the container the height of the area it covers — for a full-page overlay, position: fixed with inset: 0. The loader itself needs no changes.
Does a CSS loader slow down my page?
Practically no. The animations here only animate transform and opacity, which browsers can run on the graphics processor without repainting the page. Avoid animating width, height or margins in your own variants, because those force the browser to recalculate layout every frame.
How do I show the loader only while something is loading?
Start with the loader visible (or add it when an action begins), and hide it when the work finishes: element.style.display = 'none' is enough, or toggle a class. For form submissions, show it on submit and hide it when the response returns; for page sections, hide it once the content has been inserted.
Can I change the loader colour to match my brand?
Yes — that is the main advantage over image loaders. Pick your brand colour here and it is written into the generated CSS. On dark backgrounds choose a light, bright shade so the moving parts stay clearly visible.
Should I add text or an accessible label to a loader?
It is good practice. Screen-reader users cannot see the animation, so add role="status" and a visually hidden label such as Loading… to the loader element, or place a short visible caption under it. It also reassures sighted visitors during longer waits.