API Reference

Complete reference for all Shimmer component props and configuration options.

Shimmer Component Props

PropTypeDefaultDescription
loadingbooleantrueWhether to show shimmer effect or actual content
childrenComponent ChildrenrequiredThe content to render/measure (Slot/Children)
shimmerColorstring'rgba(255,255,255,0.15)'Color of the shimmer wave
backgroundColorstring'rgba(255,255,255,0.08)'Background color of shimmer blocks
durationnumber1.5Animation duration in seconds
fallbackBorderRadiusnumber4Border radius (px) for elements with no CSS border-radius
templatePropsRecord<string, unknown>-Props to inject into first child for skeleton rendering

Example with All Props

<Shimmer
  loading={isLoading}
  shimmerColor="rgba(255, 255, 255, 0.2)"
  backgroundColor="rgba(255, 255, 255, 0.1)"
  duration={2}
  fallbackBorderRadius={8}
  templateProps={{
    user: userTemplate,
    settings: settingsTemplate,
  }}
>
  <MyComponent user={user || userTemplate} settings={settings} />
</Shimmer>

Global Configuration

All frameworks support global configuration through their respective context/provider patterns.

React

import { ShimmerProvider } from '@shimmer-from-structure/react';

<ShimmerProvider config={{ shimmerColor: '...', ... }}>
  <App />
</ShimmerProvider>

Vue

import { provideShimmerConfig } from '@shimmer-from-structure/vue';

provideShimmerConfig({ shimmerColor: '...', ... });

Svelte

import { setShimmerConfig } from '@shimmer-from-structure/svelte';

setShimmerConfig({ shimmerColor: '...', ... });

Angular

import { provideShimmerConfig } from '@shimmer-from-structure/angular';

bootstrapApplication(AppComponent, {
  providers: [provideShimmerConfig({ shimmerColor: '...', ... })],
});

SolidJS

import { ShimmerProvider } from '@shimmer-from-structure/solid';

<ShimmerProvider config={{ shimmerColor: '...', ... }}>
  <App />
</ShimmerProvider>

Configuration Object

PropertyTypeDefaultDescription
shimmerColorstring'rgba(255,255,255,0.15)'Global shimmer wave color
backgroundColorstring'rgba(255,255,255,0.08)'Global background color for shimmer blocks
durationnumber1.5Global animation duration in seconds
fallbackBorderRadiusnumber4Global fallback border radius in pixels

Accessing Configuration

Each framework provides a way to access the current configuration:

  • React: useShimmerConfig()
  • Vue: useShimmerConfig()
  • Svelte: getShimmerConfig()
  • Angular: injectShimmerConfig()
  • SolidJS: useShimmerConfig()

HTML Attribute Controls

Control shimmer behavior at the element level using HTML data attributes. These attributes provide fine-grained control over which elements are measured and how they are rendered during the loading state.

AttributeDescriptionUse Case
data-shimmer-ignoreExcludes the element and all its descendants from shimmer measurement and rendering. Elements with this attribute remain visible during loading (text and media are not hidden).Live indicators, badges, static labels, or any content that should remain visible during loading
data-shimmer-no-childrenTreats the element as a single shimmer block. The library does not recurse into its children and uses the element's own bounding rect for the overlay.Complex nested structures where you want a single unified shimmer block instead of multiple child blocks

Example Usage

<Shimmer loading={loading}>
  <div className="card">
    {/* This badge stays visible during loading */}
    <span className="badge" data-shimmer-ignore>
      LIVE
    </span>
    
    <h2>Card Title</h2>
    <p>Card content that will be shimmered</p>
    
    {/* This entire row becomes one shimmer block */}
    <div className="metric-row" data-shimmer-no-children>
      <span>Views: 1,234</span>
      <span>Likes: 567</span>
      <span>Shares: 89</span>
    </div>
  </div>
</Shimmer>

TypeScript Support

All packages include full TypeScript definitions. Import types as needed:

import type { ShimmerProps, ShimmerConfig } from 'shimmer-from-structure';