Back

Building a Seamless Circular Animated Loader

Master the art of creating a mesmerizing animated loader with smooth transitions and dynamic visual effects that captivate users.

HTML

To create a stunning circular loader, we'll start by developing a simple HTML structure. The loader will be enclosed in a container for proper alignment. This container will enable us to easily animate and control the size and position of the loader.

        <div class="loader-container">
          <div class="loader"></div>
        </div>
      

CSS

Our CSS will bring life to the loader. We will define both the loader and its container. Let us start with the styling for the loader-container. This class will center the loader in the middle of the viewport using Flexbox.

        .loader-container {
          display: flex;
          justify-content: center;
          align-items: center;
          height: 100vh;
          background-color: #f8f9fa;
        }
      
Next, let's style the loader itself. It will be circular in shape due to the large border-radius. We'll apply gradient border colors to enhance its appearance, creating a sleek spinning animation. The use of the transform property in combination with @keyframes defines its rotation.

        .loader {
          border: 16px solid #f3f3f3;
          border-top: 16px solid #3498db;
          border-radius: 50%;
          width: 120px;
          height: 120px;
          animation: spin 2s linear infinite;
        }

        @keyframes spin {
          0% { transform: rotate(0deg); }
          100% { transform: rotate(360deg); }
        }
      
We have defined the spinning effect by rotating the loader 360 degrees continuously, making it appear as a real loader during page loads or processes.

Advanced Customizations

Customizations are key to setting your loader apart. Here are a few ideas to give your loader a unique touch:
  • Color Scheme: Alter the colors used in borders to match your application's design theme. Swapping #3498db with any hex color will change the loader's animation color.
  • Speed: Modify the speed of rotation by changing the animation-duration to create slower or faster spinning effects.
  • Size: By increasing or decreasing the width and height, you can own a loader that fits perfectly on your page.

When to Use This

The circular animated loader is ideal for:
  • Signaling background processes that might take time, ensuring users remain engaged.
  • E-commerce websites, while loading products or processing transactions.
  • Any interactive web application where operations result in delayed responses from the server.
This loader provides a visual indication during such moments, maintaining communication between the application and its users.

Conclusion

This seamless circular loader is more than just a visual element—it plays a significant role in improving user experience by conveying progress. Feel free to adapt this component further into your large-scale projects or small web applications. Its elegance lies in its simplicity, offering a versatile solution for many design needs. Utilize this component, tweak it to match your requirements, and keep users informed and engaged while they wait.

Whole code

<div class="loader-container">
  <div class="loader"></div>
</div>


<style>
.loader-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f8f9fa;
}
.loader {
  border: 16px solid #f3f3f3;
  border-top: 16px solid #3498db;
  border-radius: 50%;
  width: 120px;
  height: 120px;
  animation: spin 2s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

</style>
      
Thank you for reading this article.

Comments

More loaders

Similar

See also