Loading Indicator Shared Partial

1. Copy shared partial files

Download all 1 shared partial files as a ZIP file.

Download all files (ZIP)

After downloading, unzip and copy the loading_indicator/ folder to your app/views/shared/components/ directory.

Copy these files to your app/views/shared/components/loading_indicator/ directory:

2. Usage example

<!-- Circular spinner -->
<%= render "shared/components/loading_indicator/loading_indicator" %>

<!-- Circular spinner (colored) -->
<%= render "shared/components/loading_indicator/loading_indicator",
  color: "blue" %>

<!-- Circular spinner in a blue button -->
<button type="button" disabled class="flex items-center justify-center gap-1.5 rounded-lg border border-blue-400/30 bg-blue-600 px-3.5 py-2 text-sm font-medium whitespace-nowrap text-white shadow-sm transition-all duration-100 ease-in-out select-none hover:bg-blue-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-600 disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:outline-neutral-200">
  <%= render "shared/components/loading_indicator/loading_indicator",
    size: "sm",
    classes: "[&_svg]:text-white dark:[&_svg]:text-white" %>
  Saving...
</button>

<!-- Stepped animation loader -->
<%= render "shared/components/loading_indicator/loading_indicator",
  stepped: true %>

<!-- Stepped animation loader (colored) -->
<%= render "shared/components/loading_indicator/loading_indicator",
  stepped: true,
  color: "blue" %>

<!-- Stepped animation loader in an empty state -->
<div class="flex w-full max-w-sm flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-neutral-300 bg-neutral-50 p-6 text-center dark:border-neutral-700 dark:bg-neutral-900/50">
  <%= render "shared/components/loading_indicator/loading_indicator",
    stepped: true,
    color: "blue",
    size: "lg" %>
  <p class="text-sm text-neutral-600 dark:text-neutral-300">Loading your first project...</p>
</div>

<!-- Dots loader -->
<%= render "shared/components/loading_indicator/loading_indicator",
  type: "dots" %>

<!-- Dots loader (colored) -->
<%= render "shared/components/loading_indicator/loading_indicator",
  type: "dots",
  color: "blue" %>

<!-- Dots loader in a chat bubble -->
<div class="flex gap-2 rounded-2xl rounded-bl-md bg-neutral-100 px-4 py-3 dark:bg-neutral-800">
  <%= render "shared/components/loading_indicator/loading_indicator",
    type: "dots",
    size: "sm" %>
  <p class="text-xs text-neutral-500 dark:text-neutral-400">Support is typing...</p>
</div>

Rendered usage example

Loading your first project...

Support is typing...

Loading Indicator ViewComponent

1. Ensure the gem is installed

gem "view_component", "~> 4.2"

2. Copy component files

Download all 2 component files as a ZIP file.

Download all files (ZIP)

After downloading, unzip and copy the loading_indicator/ folder to your app/components/ directory.

Copy these files to your app/components/loading_indicator/ directory:

3. Usage example

<!-- Circular spinner -->
<%= render LoadingIndicator::Component.new %>

<!-- Circular spinner (colored) -->
<%= render LoadingIndicator::Component.new(color: :blue) %>

<!-- Circular spinner in a blue button -->
<button type="button" disabled class="flex items-center justify-center gap-1.5 rounded-lg border border-blue-400/30 bg-blue-600 px-3.5 py-2 text-sm font-medium whitespace-nowrap text-white shadow-sm transition-all duration-100 ease-in-out select-none hover:bg-blue-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-600 disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:outline-neutral-200">
  <%= render LoadingIndicator::Component.new(
    size: :sm,
    classes: "[&_svg]:text-white dark:[&_svg]:text-white"
  ) %>
  Saving...
</button>

<!-- Stepped animation loader -->
<%= render LoadingIndicator::Component.new(stepped: true) %>

<!-- Stepped animation loader (colored) -->
<%= render LoadingIndicator::Component.new(
  stepped: true,
  color: :blue
) %>

<!-- Stepped animation loader in an empty state -->
<div class="flex w-full max-w-sm flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-neutral-300 bg-neutral-50 p-6 text-center dark:border-neutral-700 dark:bg-neutral-900/50">
  <%= render LoadingIndicator::Component.new(
    stepped: true,
    color: :blue,
    size: :lg
  ) %>
  <p class="text-sm text-neutral-600 dark:text-neutral-300">Loading your first project...</p>
</div>

<!-- Dots loader -->
<%= render LoadingIndicator::Component.new(type: :dots) %>

<!-- Dots loader (colored) -->
<%= render LoadingIndicator::Component.new(
  type: :dots,
  color: :blue
) %>

<!-- Dots loader in a chat bubble -->
<div class="flex gap-2 rounded-2xl rounded-bl-md bg-neutral-100 px-4 py-3 dark:bg-neutral-800">
  <%= render LoadingIndicator::Component.new(type: :dots, size: :sm) %>
  <p class="text-xs text-neutral-500 dark:text-neutral-400">Support is typing...</p>
</div>

Rendered usage example

Loading your first project...

Support is typing...

Loading indicators Rails Components

Visual feedback indicators to show users that content is loading or processing. Built with Tailwind CSS and SVGs.

Examples

Circular spinner

A classic circular loading spinner with a rotating arc. Perfect for general loading states.

<div class="flex items-center justify-center p-8">
  <svg xmlns="http://www.w3.org/2000/svg" class="rounded-full animate-spin size-8 text-neutral-800 dark:text-neutral-200" width="18" height="18" viewBox="0 0 18 18">
    <g fill="currentColor">
      <path d="m9,17c-4.4111,0-8-3.5889-8-8S4.5889,1,9,1s8,3.5889,8,8-3.5889,8-8,8Zm0-14.5c-3.584,0-6.5,2.916-6.5,6.5s2.916,6.5,6.5,6.5,6.5-2.916,6.5-6.5-2.916-6.5-6.5-6.5Z" opacity=".4" stroke-width="0"></path>
      <path d="m16.25,9.75c-.4141,0-.75-.3359-.75-.75,0-3.584-2.916-6.5-6.5-6.5-.4141,0-.75-.3359-.75-.75s.3359-.75.75-.75c4.4111,0,8,3.5889,8,8,0,.4141-.3359.75-.75.75Z" stroke-width="0"></path>
    </g>
  </svg>
</div>

Stepped animation loader

A stylish loader variant with a stepped animation.

<div class="flex items-center justify-center p-8">
  <svg xmlns="http://www.w3.org/2000/svg" class="size-8 rounded-full animate-[spin_0.8s_steps(8)_infinite]" width="18" height="18" viewBox="0 0 18 18">
    <g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
      <line x1="9" y1="1.75" x2="9" y2="4.25" opacity=".13"></line>
      <line x1="14.127" y1="3.873" x2="12.359" y2="5.641" opacity=".25"></line>
      <line x1="16.25" y1="9" x2="13.75" y2="9" opacity=".38"></line>
      <line x1="14.127" y1="14.127" x2="12.359" y2="12.359" opacity=".5"></line>
      <line x1="9" y1="16.25" x2="9" y2="13.75" opacity=".63"></line>
      <line x1="3.873" y1="14.127" x2="5.641" y2="12.359" opacity=".75"></line>
      <line x1="1.75" y1="9" x2="4.25" y2="9" opacity=".88"></line>
      <line x1="3.873" y1="3.873" x2="5.641" y2="5.641"></line>
    </g>
  </svg>
</div>

Dots loader

A playful bouncing dots animation. Great for minimal interfaces and inline loading states.

<div class="flex items-center justify-center p-8">
  <div class="flex space-x-1.5">
    <div class="size-1.5 bg-neutral-800 dark:bg-neutral-200 rounded-full animate-bounce" style="animation-delay: 0ms;"></div>
    <div class="size-1.5 bg-neutral-800/80 dark:bg-neutral-200/80 rounded-full animate-bounce" style="animation-delay: 150ms;"></div>
    <div class="size-1.5 bg-neutral-800/60 dark:bg-neutral-200/60 rounded-full animate-bounce" style="animation-delay: 300ms;"></div>
  </div>
</div>

Usage

These spinners can be easily customized by adjusting the Tailwind to change the size & colors of the loader.

Table of contents

Powered by

Get notified when new components come out