Loading

Show progress with an animated circular indicator around your logo or icon.

Keep your logo visible while content loads. Loading uses the same expanding and contracting spinner animation as Preloader, around a stationary image or icon.

Loading your workspace…

Basic usage

The indicator works with CSS alone using the standard Preloader markup below. Toggle active on the outer loading element to show or hide the spinner; keep active on the inner preloader-wrapper. Place your image inside loading-content, or leave the content out for a plain spinner.

<div class="loading active" role="status" aria-label="Loading workspace" aria-busy="true">
  <div class="preloader-wrapper active" aria-hidden="true">
    <div class="spinner-layer">
      <div class="circle-clipper left"><div class="circle"></div></div>
      <div class="gap-patch"><div class="circle"></div></div>
      <div class="circle-clipper right"><div class="circle"></div></div>
    </div>
  </div>
  <span class="loading-content">
    <img src="images/materialize.svg" alt="">
  </span>
</div>

Sizes and content

Use loading-small (4rem), the default (7rem), or loading-large (10rem). Images fit inside the ring without being stretched.

Small · spinner

Default · icon

Large · logo

<div class="loading loading-small active" role="status" aria-label="Loading" aria-busy="true">
  <div class="preloader-wrapper active" aria-hidden="true">
    <div class="spinner-layer">
      <div class="circle-clipper left"><div class="circle"></div></div>
      <div class="gap-patch"><div class="circle"></div></div>
      <div class="circle-clipper right"><div class="circle"></div></div>
    </div>
  </div>
</div>

<div class="loading active" role="status" aria-label="Syncing files" aria-busy="true">
  <div class="preloader-wrapper active" aria-hidden="true">
    <div class="spinner-layer">
      <div class="circle-clipper left"><div class="circle"></div></div>
      <div class="gap-patch"><div class="circle"></div></div>
      <div class="circle-clipper right"><div class="circle"></div></div>
    </div>
  </div>
  <span class="loading-content">
    <i class="material-icons" aria-hidden="true">cloud_sync</i>
  </span>
</div>

Customization

Colors follow the current theme, including dark mode. Override these CSS properties on an individual indicator to match your brand.

.loading {
  --loading-size: 9rem;
  --loading-color: var(--md-sys-color-tertiary);
  --loading-background: var(--md-sys-color-tertiary-container);
  --loading-thickness: 5px;
}
PropertyDefaultPurpose
--loading-size7remWidth and height of the indicator.
--loading-colorTheme primaryRing and icon color.
--loading-backgroundTheme surface containerCircular background.
--loading-thickness3pxRing stroke width.

JavaScript controls

Initialize Loading to keep the animation and accessible status in sync. The JavaScript API adds the Preloader markup automatically when it is missing. Stopping hides the ring and keeps your logo visible.

Ready to load.

const loading = M.Loading.init(document.querySelector('#loading-demo'), {
  active: false,
  label: 'Loading workspace…',
  completeLabel: 'Workspace ready'
});

loading.start();
// When your operation finishes:
loading.stop();

// Override the status for a specific operation:
loading.start('Refreshing assets…');
loading.stop('Assets ready');

For ES modules, use import { Loading } from 'kmaterialize'. M.AutoInit() initializes .loading elements automatically; add no-autoinit when initializing manually.

Options
OptionDefaultDescription
activetrueStart animating on initialization.
labelLoading…Accessible loading status. Uses the element’s existing aria-label when this option is omitted.
completeLabelReadyAccessible status after stopping.
Methods and properties
APIDescription
start(label?)Animate the ring and set aria-busy to true.
stop(label?)Hide the ring and set aria-busy to false.
isActiveRead whether the indicator is active.
Loading.getInstance(element)Retrieve an initialized instance.
destroy()Remove the instance and restore the original classes and accessibility attributes.

Accessibility

Give the indicator a meaningful status using aria-label. Keep decorative images empty with alt="", and hide decorative icons from assistive technology with aria-hidden="true".

For CSS-only usage, update aria-busy and the status label when toggling active. The JavaScript API handles these attributes for you. If a separate region is being updated, manage that region’s aria-busy as part of your operation too.

When the user requests reduced motion, the ring stays visible without rotating. Loading is a status indicator; use a separate button for actions.

For linear progress bars and traditional circular spinners, see Preloader.