A CSS loader generator example is a bordered HTML element animated by a 360-degree CSS keyframe rotation to signal that an application operation is still running.
The CSS Loader Generator creates this baseline locally in your browser. You configure the dimensions, ring width, colors, and timing, preview the result, and copy the CSS without adding an image, SVG file, JavaScript animation loop, or third-party package.

What the generator actually outputs
The generated spinner uses a deliberately simple CSS structure. Equal width and height create a square box, while a circular border radius turns it into a ring. The complete border represents the track color, and border-top-color replaces one segment with the active color. A keyframe rotates the element through 360 degrees using a transform.
- The .loader class contains the selected size, ring width, colors, border radius, and animation shorthand.
- A uniquely named @keyframes rule performs the full rotation using linear timing and infinite repetition.
- The live preview uses role="status" and an aria-label, while matching the dimensions, border, color, and timing used in the copied CSS.
Because the loader is drawn with CSS geometry rather than a raster image, it remains sharp at different pixel densities. The copied CSS is only the visual baseline, however; it does not know when an operation begins, succeeds, fails, or gets cancelled.
Configure the ring in four steps
- Choose the spinner size and ring width. The overall size can range from 12 through 160 pixels. Ring width must be at least 1 pixel and cannot exceed half the selected size, because a thicker border can collapse or invert the visible opening rather than forming a clear ring.
- Set the active and track colors. Both colors must use six-digit hexadecimal notation. Choose colors with enough visual distinction that users can perceive the rotating segment, but do not rely on color alone to communicate the loading state.
- Adjust the duration while watching the live preview. Durations range from 0.2 through 5 seconds. Very fast movement can be uncomfortable, while a very slow rotation may appear frozen, so compare the preview with the speed expected for the actual task.
- Copy the CSS and complete the implementation. Add accessible status information, a reduced-motion rule, and application logic that displays the loader only while work is active. Rename the .loader class or generated keyframes if your stylesheet already uses those identifiers.
A CSS loader generator example to adapt
The following example uses a 48-pixel spinner, a 6-pixel ring, a light-gray track, a blue active segment, and a 0.8-second rotation. These values fall within the generator’s accepted ranges.
HTML:
<div class="loader" role="status" aria-label="Loading results"></div>
CSS:
.loader { width: 48px; height: 48px; border: 6px solid #d8dee9; border-top-color: #2563eb; border-radius: 50%; animation: ring-rotate 0.8s linear infinite; } @keyframes ring-rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
The name ring-rotate is used here for readability. Replace it with the unique keyframe name from the copied output, and rename the .loader class too if that identifier already exists in your project.
Reduced-motion replacement:
@media (prefers-reduced-motion: reduce) { .loader { animation: none; } }
Place the reduced-motion rule after the generated CSS so it overrides the animation shorthand. This example replaces continuous rotation with a static ring while the status message continues to explain the active task. If your product policy permits slow movement, a longer duration can be used instead of removing the animation.
Connect the spinner to real application states
A CSS animation cannot determine when it should appear or disappear. The surrounding application must start the loader when work begins, connect it to the real request or task, and remove it after every terminal outcome. For a fetch operation, that normally means showing the loader before the request, then clearing it after success, failure, timeout, or cancellation.
| Application state | Recommended interface | Important detail |
|---|---|---|
| Pending | Show the ring with an accessible name or nearby status text. | Describe the actual task, such as “Loading results” or “Uploading file.” |
| Success | Remove the ring promptly and display the completed result. | Do not leave the animation running after the operation has finished. |
| Measurable progress | Use a progress bar with a value when progress can be calculated. | A progress bar with a value is often more informative than an indeterminate spinner. |
| Error or timeout | Remove the spinner and expose a clear failure message. | Provide retry or recovery options where appropriate. |
| Cancellation | Remove the spinner and indicate that the operation was cancelled. | Do not leave an active animation suggesting that work continues. |
Never keep an animation running to conceal a failed or stalled operation. Test with realistic network delays, confirm that the loader disappears after success, cancellation, and error, and render it only in the area that needs feedback. Many simultaneous spinners can create visual noise and consume resources even though one CSS rotation is generally inexpensive.
Make the feedback understandable and resilient
The preview includes status semantics, but copied CSS does not add them to your page. Give the production loader an accessible name that matches the current task, or place meaningful status text beside it. The spinner should not be the only indication that content is loading. Users also need to understand the result after the operation ends.
Do not repeatedly announce rapid, minor updates. If progress is measurable, expose the current value through an appropriate progress control rather than repeatedly changing a live status message. For measured progress, a progress bar with a value can communicate more than an indeterminate ring.
Continuous rotation should respect the user’s reduced-motion preference. The example above provides a static replacement, but each product should define whether it slows, simplifies, or removes movement. For broader implementation guidance, consult MDN’s guide to using CSS animations and the W3C CSS Animations Level 1 specification.
Test the loader against high-contrast settings, forced-colors modes, dark themes, browser zoom, and small screens. Confirm that the track and active segment remain distinguishable and that surrounding text stays readable. Reserve layout space before the loader appears so content does not shift when feedback is inserted or removed.
Check the accepted values and failure cases
The generator validates each value before using it in the preview. These limits prevent settings that could produce a broken ring or unusable animation.
| Input | Accepted value | Practical reason |
|---|---|---|
| Overall size | 12 through 160 pixels | Keeps the ring within the generator’s bounded preview range. |
| Ring width | At least 1 pixel and no more than half the selected size | Prevents the border from collapsing or inverting the inner opening. |
| Duration | 0.2 through 5 seconds | Excludes movement that may be uncomfortable or appear frozen. |
| Active and track colors | Six-digit hexadecimal values | Keeps the generated border colors explicit and consistent. |
| Invalid numeric entry | Empty fields become invalid; non-finite values are rejected | Prevents an empty field from silently becoming zero or producing an unusable result. |
For a compact reference while tuning a spinner, see the CSS Loader Generator cheat sheet for inputs, bounds, and output.
Separate the generated CSS from application logic
The generator supplies a visual component, not a complete loading system. It does not add:
- JavaScript state management for starting, completing, or cancelling work
- Overlay positioning or modal behavior
- Skeleton content for unfinished page regions
- Progress calculation for measurable operations
Those decisions belong in the surrounding application, where the request lifecycle, failure conditions, and interface hierarchy are known. All generator work happens locally in the browser: settings are not uploaded or retained, no account is required, and no new dependency is introduced. Treat the copied CSS as a reusable ring-spinner baseline, then add the status, motion policy, and lifecycle behavior required by the real task.
For a deeper look, see CSS Speech Bubble Generator Explained: Inside the CSS.