Loading Spinner CSS Generator

Next

A loading spinner shows visitors that a page, panel or button is still working. Set the size, ring thickness, color and speed below, watch the preview, then copy the finished loading spinner CSS into your stylesheet.

How to get your loading spinner CSS

  1. 1

    Pick a size

    Enter the diameter in pixels. Around 40 to 60 for a content area, smaller for inline use.

  2. 2

    Choose thickness and color

    Set the ring thickness in pixels and pick the color of the moving arc with the color field.

  3. 3

    Set the speed

    Enter the seconds for one full turn. 1 is a common default.

  4. 4

    Copy the CSS

    Use the copy button next to the CSS box and paste the rules into your stylesheet.

What you get

The generator writes two rules: a .loader class and a @keyframes spin block. The class draws a circle, gives it a light gray ring and colors the top edge of that ring. The keyframes turn the circle one full rotation, and the animation line repeats it forever. Nothing else is needed: no image file, no icon font and no script.

With the default values (60 px, 6 px ring, #10b981, 1 second) the output looks like this:

.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); }
}

Add it to your page

Paste the CSS into your stylesheet, then add one empty element where the loader should appear:

<div class="loader" role="status" aria-label="Loading"></div>

Show the element while the work is running and remove it, or hide it with display: none, when the content arrives. The role and aria-label attributes let screen readers announce the state.

Sizes that work

Where it sits Size Thickness
Inside a small button 16 to 20 px 2 px
Next to a line of text 20 to 28 px 3 px
Card or panel 40 to 60 px 4 to 6 px
Centered on an empty page 60 to 100 px 6 to 8 px

A rule of thumb is a thickness of about one tenth of the diameter. Much thinner looks faint on high-resolution screens, and much thicker turns the ring into a blob.

Things to know

  • The track color is fixed at light gray (#eee). On a dark background, edit that value in the pasted CSS.
  • The tool makes one circular spinner. Dots, bars and other shapes need different markup.
  • If a class called loader or an animation called spin already exists in your project, rename them in the pasted CSS so the rules do not collide.

Showing and hiding it

A loading spinner should appear when work starts and disappear when it ends. A simple pattern is to keep a hidden attribute on the element and remove it when a request begins. If the wait is usually very short, add a small delay of a few hundred milliseconds before showing the ring, so quick responses do not flash a spinner for an instant. Whatever you choose, always hide the spinner in the error case too, or visitors will wait for something that already failed.

Frequently Asked Questions

Yes. The output is plain CSS with one class and one keyframes rule, so it works in any stylesheet or style block, with any back end.

Keep the element hidden by default and show it when the request starts. Hide it again when the request finishes. You control that with a class toggle or a hidden attribute in your own code.

The generated CSS colors only the top border of the circle. When the circle rotates, that single colored arc travels around the light gray ring, which creates the spinning look.

Yes. Every value is a normal CSS property, so you can edit the width, border, color or animation time directly in your stylesheet.

Related Tools

Tool available in other languages

Guides and use cases