Spinner on Button CSS Generator

Next

A spinner inside a button tells people their click worked and that they should not press it again. Generate a small, thin ring here, then copy the CSS and place it beside the button label.

How to make a button spinner

  1. 1

    Use a small size

    Enter 16 or 18 in the size field so the ring fits the button text height.

  2. 2

    Make the ring thin

    Set the thickness to 2 so the arc stays crisp at this size.

  3. 3

    Match the color

    Pick the color of the moving arc, for example white on a dark button.

  4. 4

    Speed up slightly and copy

    Try 0.8 seconds per turn, then copy the CSS.

A worked example

Suppose you have a dark blue “Save” button with white text. In the generator, enter size 16, thickness 2, color #ffffff and speed 0.8. The tool produces:

.loader {
  width: 16px;
  height: 16px;
  border: 2px solid #eee;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

The ring track is a fixed light gray, which is visible on a dark button. If you want a subtler track, change #eee to a translucent value such as rgba(255, 255, 255, 0.3) in the pasted CSS. The arc color stays whatever you picked.

Place it inside the button

Put the spinner element before the label and make the button a flex row so they sit on one line with a gap:

<button class="save" type="submit" disabled>
  <span class="loader" role="status" aria-label="Saving"></span>
  Saving
</button>
.save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

Add the spinner and the disabled state only while the request is running. Remove both when it finishes. Disabling the button is what stops double submissions; the spinner is the signal that explains why.

Size and thickness for buttons

Button text size Spinner size Thickness
14 px 14 px 2 px
16 px 16 to 18 px 2 px
18 to 20 px 20 to 24 px 3 px

Notes

  • The generator makes one circular ring. It does not create a button, so your button styles stay your own.
  • A ring thicker than a quarter of its diameter fills up and looks like a disc, so keep thin values at small sizes.
  • Keep the label next to the spinner. A spinner with no text can be hard to interpret for some users.

Avoid layout jumps

If the spinner appears and the button suddenly grows wider, the layout shifts and the click target moves. Two easy fixes help. Give the button a minimum width that already fits the spinner and the longer label. Or reserve the spinner space from the start by showing an empty 16 px placeholder before the label. Because the generated ring has a fixed width and height in pixels, it is easy to reserve exactly the room it needs.

Frequently Asked Questions

About the same height as the button text, usually 14 to 20 pixels. That keeps the button from growing when the spinner appears.

Yes, in most forms. Disabling prevents duplicate submissions, and the spinner explains to the visitor why nothing else is clickable.

The track is light gray and the arc is the color you choose. On a light button, pick a darker arc color and change the track color in the pasted CSS.

No. The generator only outputs the ring CSS. Whether you keep, change or hide the label is up to your markup.

Related Tools

Tool available in other languages

Guides and use cases