Image component with animated shimmer placeholder, blur-to-clear loading effect, and configurable intent, visuals, shape, and elevation variants.
Made by raouf.codesOverview
Core Concept
The BlurImage component wraps Next.js Image to provide an enhanced loading experience with a shimmer animation and blur-to-clear transition. Built with class-variance-authority, it offers configurable intent, visuals, shape, and elevation variants for consistent styling across your application.
Key Features
- Shimmer animation — A subtle overlay sweeps across the placeholder while loading
- Blur-to-clear transition — Image starts blurred and scales down smoothly as it loads
- Default placeholder — Falls back to a neutral gray SVG placeholder
- Custom placeholder support — Provide your own
blurDataURLfor branded loading states - Intent variants — Apply semantic color (
primary,accent,secondary,success,info,warning,error,neutral) that controls background, text, and border colors - Visual variants — Apply
solid,dashed,dotted, ornoneborder styling - Shape variants — Control border radius with
rounded,pill, orsharp - Elevation variants — Control drop shadow:
none,raised,floating - SSR compatible — Works seamlessly with Next.js server-side rendering
Installation
Usage
Basic
Composition
Combine with grid layouts or card components for gallery views:
Custom Placeholder
You can provide your own base64-encoded placeholder image:
API Reference
BlurImage
| Prop | Type | Default |
|---|---|---|
src | string | - |
alt | string | - |
width? | number | 400 |
height? | number | 210 |
intent? | enum | "primary" |
visuals? | enum | "none" |
shape? | enum | "rounded" |
elevation? | enum | "none" |
blurDataURL? | string | - |
className? | string | - |
...props? | ImageProps | - |
Accessibility
- Required
altattribute — Enforces descriptive alt text for screen readers - Decorative images — Use
alt=""for purely decorative images - Reduced motion — Shimmer animation respects
prefers-reduced-motionwhen styled appropriately
Notes
- The shimmer animation requires the
shimmerkeyframe in your CSS. Add this to your global styles:
- For production, consider a server-side preprocessing step to generate low-resolution data URLs for all remote assets.
Built by raouf.codes. The source code is available on GitHub.
Last updated: 5/15/2026
