Skip to content
Guide

How to Add a CSS Loading Spinner (That’s Actually Accessible)

Brisqnex TeamNov 30, 20266 min read

CSS Loader Generator guide graphic: a spinning loader icon in the centre, with code, accessibility, palette and timer icons around it

A CSS loading spinner is about the smallest piece of interface you can build. A ring, a colour, a rotation, maybe twenty lines of CSS. That’s also why it’s easy to get wrong without noticing: it looks finished the moment it spins.

Most CSS loader generators stop at that point. You pick a shape, copy the code, and get a tidy animation with nothing for screen reader users and nothing for people who’ve asked their device for less motion. The CSS Loader Generator on this site handles both by default. Below is how to use it, what the extra lines in its output are for, and the two or three things you still have to do yourself.

What you get

Eight pure CSS loaders: a ring spinner, a dual ring, three bouncing dots, bars, a pulse, a ripple, an indeterminate progress bar and a dashed circle. No images, and no JavaScript for the animation itself. You set the size, colour, thickness and speed, and all eight previews redraw with your settings so you can compare them side by side.

You copy two snippets. The HTML is a div with the class loader, any dots or bars the style needs, and a label. The CSS holds the loader’s rules, its @keyframes and a reduced-motion block. Every animation and delay runs off one custom property, --loader-speed, so if the spinner feels sluggish next month you change one number instead of hunting through keyframes.

What most loading animation CSS leaves out

A spinning shape means nothing to someone who can’t see it. To a screen reader, a div with a CSS animation on it is just an empty box. The generated markup puts role="status" on the wrapper, which makes it a polite live region, and adds a “Loading…” label inside that’s hidden from view but still read out. Someone using a screen reader hears that something is happening, instead of wondering whether their click did anything at all.

The second gap is motion. Some people switch on their device’s reduce-motion setting because animation makes them dizzy or sick, not because they find it mildly annoying. A ring rotating in the middle of the screen is exactly what that setting is meant to calm down. The generated CSS checks prefers-reduced-motion, and you choose what it does for those visitors:

  • Slow it down: each cycle takes three times as long. The loader still shows that work is happening, just gently.
  • Stop it: the animation is switched off and the loader stays on screen as a still shape. The label still tells screen reader users what’s going on.

Slowing down is the default, and it suits most loaders, because a frozen spinner can look like a frozen page. Stopping makes more sense for a large loader that fills a whole panel.

How to make one

  1. Pick a style in the gallery. The styles are radio buttons, so once you Tab into the group, the arrow keys move between them.
  2. Set the size in pixels. For the progress bar that’s its width; for the bouncing dots it’s the width of the whole row.
  3. Choose a colour with the picker or type a hex code, then set the thickness if the style has one: ring thickness, bar width, bar height or dash thickness.
  4. Set the speed as the length of one cycle in seconds. Smaller numbers are faster, and the default is 1 second.
  5. Choose what happens when a visitor has asked for reduced motion: slow down or stop.
  6. Copy the HTML to where the loader should appear and the CSS into your stylesheet.

Check the colour before it goes live. A loader counts as a graphic, so it needs at least 3:1 contrast against whatever sits behind it. Put both colours into the Color Contrast Checker and it gives you the ratio. Pale brand colours on a white background miss more often than you’d think.

The limits, and why they’re there

Size runs from 16 to 400 px, and one cycle from 0.2 to 10 seconds. Thickness is capped at a quarter of the size, so a 48 px ring can be at most 12 px thick. The cap can feel arbitrary the first time you hit it, but past that point a ring stops looking like a ring and starts looking like a thick disc with a small hole, and bars crowd into each other. If you want something chunkier, make the whole loader bigger and the cap rises with it.

After you paste it in

The CSS animates the element for as long as it’s on the page, so taking it away is your job. Insert the HTML when loading starts, and remove or hide it the moment the content arrives. A CSS spinner left in the page after everything has loaded keeps telling screen readers that something is still loading, which is confusing for exactly the people the label was added for.

Then change the label. “Loading…” is a safe default, but “Saving…”, “Loading results…” or “Uploading photo…” tell people what they’re waiting for. It’s a one-word edit in the HTML.

Two loaders on one page

Every snippet uses the class loader. Paste two different styles into the same page and the second set of rules overrides the first, so you end up with an odd mix of both. The fix is to rename the class in one of them, in four places: the class in the HTML, the CSS selectors, the @keyframes name and the custom property (--loader-speed might become --save-loader-speed). Run find and replace over the copied snippet before you paste it, and you won’t miss one.

These are free CSS loaders, and the same set-it-up-then-copy approach works for other parts of the interface too, in the Box Shadow Generator and the CSS Background Pattern Generator.

Quick answers

Do I need JavaScript to use this? Not for the animation, which is pure CSS. You only need your own code, or your framework, to add the element when loading starts and remove it when it ends.

Will this work in older browsers? It uses CSS custom properties, calc() and transforms, which every current browser supports. A very old browser without custom properties shows the loader without the animation.

Why won’t my loader get thicker? Thickness can be at most a quarter of the size. Increase the size and you can make it thicker.

What if I need two loaders on the same page? Rename the class, the selectors, the keyframes name and the custom property in one of the snippets, so the two don’t override each other.

To see the difference for yourself, copy the ring spinner from the CSS Loader Generator into a test page and leave the default “slow down” setting. Then turn on Reduce motion (on a Mac: System Settings, Accessibility, Display; on Windows: Settings, Accessibility, Visual effects, and switch off Animation effects) and reload. Watch the spinner slow to a third of its speed. That’s the version some of your visitors have been asking for.

Back to all articles

Ready to save some time?

Browse 83 free tools — no signup, no hidden charges.

Explore Tools