Free tool · Developer tools
CSS loader and spinner generator
A 48 px ring that turns once every 0.8 seconds is a short block of CSS. Pick a style, set the size, thickness, color and speed, check the live preview and copy the HTML and the CSS.
- Free
- No sign-up
- Runs in your browser
48 px ring0.8 s per cycle, #2563eb
- Pure CSS
- No images
- No JavaScript needed
- Size
- 48 px
- Inner diameter
- 38 px
- Track color
- rgba(37, 99, 235, 0.2)
- One cycle
- 0.8 s, 75 per minute
- Color
- #2563eb
<!-- HTML -->
<div class="loader-box" role="status"><div class="loader"></div><span class="loader-text">Loading</span></div>
/* CSS */
.loader {
box-sizing: border-box;
width: 48px;
height: 48px;
border: 5px solid rgba(37, 99, 235, 0.2);
border-top-color: #2563eb;
border-radius: 50%;
animation: loader-spin 0.8s linear infinite;
}
@keyframes loader-spin {
to { transform: rotate(360deg); }
}
.loader-box {
position: relative;
display: inline-block;
}
.loader-text {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
.loader { animation-duration: 2.4s; }
}| Seconds per cycle | Cycles per minute | Degrees per second (ring) |
|---|---|---|
| 0.4 | 150 | 900 |
| 0.6 | 100 | 600 |
| 0.8 | 75 | 450 |
| 1 | 60 | 360 |
| 1.5 | 40 | 240 |
| 2 | 30 | 180 |
How to use the CSS Loader Spinner Generator
- Choose a Style: ring, three dots, four bars or pulse.
- Set the Size, the Thickness, the Color (hex) and the Seconds per cycle.
- Watch the preview and read the facts, such as the inner diameter of a ring.
- Press Copy the code and paste the HTML and the CSS into your page.
How do you make a CSS loading spinner?
A ring spinner is a square element with a round border. The border is drawn in a faint version of your color on all sides and in the full color on the top side only, so a colored arc appears on a pale track. An animation then rotates the element 360 degrees again and again with linear timing, which keeps the speed even. For #2563eb the page writes the faint color as rgba(37, 99, 235, 0.2), the same color at 20 percent opacity, worked out from the hex value.
The core of the CSS the page produces for the default ring is short enough to read in one go. The copied code adds a hidden text rule and a reduced motion rule after it:
.loader { box-sizing: border-box; width: 48px; height: 48px; border: 5px solid rgba(37, 99, 235, 0.2); border-top-color: #2563eb; border-radius: 50%; animation: loader-spin 0.8s linear infinite; } @keyframes loader-spin { to { transform: rotate(360deg); } }
What size, thickness and speed look right?
Thickness sets the width of the arc. A 48 px ring with a 5 px border leaves an inner circle of 38 px, found by taking away two borders from the size. Thin rings feel light and thick ones feel heavy, and a border above half the size would close the hole, so the page refuses it.
Speed is the time for one cycle. At 0.8 seconds the ring makes 75 turns a minute. Quicker cycles look nervous and slower ones can look stuck, and the table lists common choices with the matching turn rates.
| Seconds per cycle | Cycles per minute | Degrees per second (ring) |
|---|---|---|
| 0.4 | 150 | 900 |
| 0.6 | 100 | 600 |
| 0.8 | 75 | 450 |
| 1 | 60 | 360 |
| 1.5 | 40 | 240 |
| 2 | 30 | 180 |
How do the dots, bars and pulse styles work?
The three dots and the four bars share one animation and start it at different moments. Negative animation delays do this: the second dot starts the animation 16 percent of a cycle ahead and the first starts 32 percent ahead, so they bounce in a wave from the first frame. The bars use delays of 12, 24 and 36 percent of the cycle in the same way. Bar width comes from the thickness field, so a 48 px loader with 5 px bars leaves a gap of 9.33 px between them, and the page checks that four bars fit.
The pulse style is a single circle that grows from nothing to full size while it fades out, then repeats.
How do I add the loader to a page?
Paste the HTML where the content will appear and the CSS into your stylesheet. The wrapper carries role="status" and holds the word Loading in text that is hidden from the eye but read by assistive software, so people who cannot see the spinner learn that something is loading. The CSS also includes a prefers-reduced-motion rule that slows the animation to three times the cycle time, at least 2.4 seconds, for people who ask their system for less motion. Remove the element, or hide it, as soon as the content arrives, because a loader that never stops tells people nothing. The class name is loader in the copied code, with loader-box and loader-text for the wrapper and the hidden text. Rename them if they clash with a class you already use, and change the keyframe names with it.
The CSS uses only widths, borders, backgrounds and transforms, so it needs no images and no script.
Use it with
- Box Shadow Generator: visual CSS box-shadow builder.
- HEX to RGB Converter: HEX, RGB, HSL, CMYK conversions.
- CSS Grid Generator: build a CSS grid layout and copy the code.
Questions
How do I make a spinner with only CSS?
Give a square element a round border, color one side of it and rotate the element with a keyframe animation. The page writes it for you, for example a 48 px ring that turns every 0.8 seconds.
How do I change the speed of the animation?
Change Seconds per cycle. A smaller number is faster: 0.8 seconds is 75 cycles a minute, and 2 seconds is 30.
Why is my loader square or squashed?
The width and the height must match and the border must be counted inside them. The ring code sets box-sizing: border-box so the border stays inside the size you chose.
Can I use a color name instead of hex?
The page asks for hex, such as #2563eb or the short form #26e, because it needs the red, green and blue values to make the pale track color of the ring.
What is the thickness for the dots?
Nothing. Dots are a quarter of the size, and pulse fills the full size. Thickness changes the ring border and the bar width only.
Is anything I enter sent away?
No. The preview and the code are made on your device, and nothing is stored or sent.
The tool's results are computed in your browser by the code on this page; the explanations are checked against the tool's own output.