How it works
This is the plain CSS rotate animation: an element spinning a full 360 degrees, as many times as you want. It is the base for spinning icons, refresh buttons, sync indicators, decorative badges and logos that turn slowly in the background.
The keyframe has two steps, from transform: rotate(0deg) to rotate(360deg). Because 360 degrees looks identical to 0, the loop has no visible jump. Everything interesting happens in the animation properties, which the preset exposes directly: Duration, Easing, Direction (normal, reverse or alternate) and Iterations (infinite, 1, 2, 3 or 5). Fill-mode both keeps the element at its final angle when a finite animation ends.
Parameters also include Size, Color and Corner radius on the demo square. Combine them for different uses. Linear easing with infinite iterations gives a steady spin for loaders and sync icons. Iterations 1 with expo-out turns it into a single "refreshed" flourish. Alternate makes the element turn forward then back, which works for a wobbling bell or settings gear. Slow durations (10s and up) suit decorative rotating text badges.
Rotation is pure transform, so it is composited and smooth at any size. Note that a fully round shape (Corner radius at half of Size) shows no visible rotation; spin something with an asymmetric detail. Continuous decorative spinning should stop under prefers-reduced-motion.
How do I rotate 360 degrees infinitely in CSS?
Define a keyframe from rotate(0deg) to rotate(360deg) and apply it with linear easing and infinite iteration count, for example animation: rotate 2s linear infinite. Linear matters: any other easing slows the element down at the end of each turn, which looks like a stutter when the turns are chained together.
How do I rotate an element only once, on click?
Set Iterations to 1 in the editor and copy the code. Then add the animation class with JavaScript when the button is clicked and remove it on animationend, so the next click can replay it. In the React version, you can increment a key or toggle the animate target to trigger the turn again.
Why does my rotating element wobble?
Usually the transform-origin is not at the visual center, for example when an icon has uneven padding inside its viewBox or the element has an odd pixel size. Set transform-origin: center explicitly and make sure the box is square. For SVG icons, transform-box: fill-box helps center rotation on the drawn shape.