You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

zenui-image-react

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zenui-image-react

Render responsive images with lazy loading and optimized performance using customizable placeholders and skeletons.

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
1
-66.67%
Maintainers
0
Weekly downloads
 
Created
Source

ZenUI Image React

A highly customizable, performance-focused React component for lazy loading images with advanced features like placeholder effects, image optimization, and responsive loading.

cover image

Try it with our Playground

Features

  • 🎯 Lazy Loading: Load images only when they enter the viewport
  • 🖼 Placeholder Support: Multiple placeholder types while images load
  • 🎨 Effect Transitions: Smooth transitions with blur, opacity, or color effects
  • 📱 Responsive Images: Automatic srcset and sizes generation
  • Performance Optimized: Intersection Observer for efficient lazy loading
  • 🛠 Highly Customizable: Extensive props for fine-tuning behavior
  • 📦 Lightweight: Small bundle size.

If our GitHub repository reaches 200 stars ⭐, we will proudly launch the Vue version of this package.

Star the Repository on GitHub

Installation

npm install zenui-image-react

Basic Usage

import { LazyLoadImage } from 'zenui-image-react';

function MyComponent() {
  return (
    <LazyLoadImage
      src="https://example.com/image.jpg"
      alt="Example"
      placeholderType="effect"
      effectType="blur"
    />
  );
}

Advanced Features

1. Placeholder Types

Choose from multiple placeholder types while your image loads:

// Effect Placeholder (blur, opacity, or color)
<LazyLoadImage
  src="image.jpg"
  placeholderType="effect"
  effectType="blur"
  effectAmount={10}
/>

// Custom Image Placeholder
<LazyLoadImage
  src="image.jpg"
  placeholderType="image"
  placeholderImage="placeholder.jpg"
/>

// Custom Component Placeholder
<LazyLoadImage
  src="image.jpg"
  placeholderType="custom"
  customPlaceholder={<MyCustomLoader />}
/>

2. Image Optimization

Enable automatic responsive image optimization:

<LazyLoadImage
  src="image.jpg"
  optimize
  quality={80}
  breakpoints={{
    sm: 576,
    md: 768,
    lg: 992,
    xl: 1200
  }}
  imageWidths={{
    sm: [576],
    md: [768],
    lg: [992],
    xl: [1200]
  }}
/>

3. Custom Loading Behavior

Control the intersection observer and loading offset:

<LazyLoadImage
  src="image.jpg"
  useIntersectionObserver={true}
  offset={200} // Start loading 200px before entering viewport
  onLoad={() => console.log('Image loaded')}
  onError={(e) => console.error('Load failed:', e)}
/>

API Reference

Props

PropTypeDefaultDescription
srcstringRequiredImage source URL
altstring''Alt text for the image
classNamestring''CSS class name
styleobject{}Inline styles
placeholderTypeenum'none'Type of placeholder ('none', 'effect', 'image', 'custom')
effectTypeenum'blur'Effect type ('blur', 'opacity', 'color')
effectAmountnumber10Intensity of the effect
placeholderImagestring-URL for placeholder image
customPlaceholderelement-Custom React component as placeholder
optimizebooleanfalseEnable responsive image optimization
qualitynumber80Image quality (1-100) when optimize is true
breakpointsobject-Custom breakpoints for responsive loading
imageWidthsobject-Width configurations for each breakpoint
sizesstring-Custom sizes attribute for responsive images
useIntersectionObserverbooleantrueEnable/disable intersection observer
offsetnumber0Loading offset in pixels
onLoadfunction-Callback when image loads
onErrorfunction-Callback when image fails to load

Default Breakpoints

{
  xs: 320,
  sm: 576,
  md: 768,
  lg: 992,
  xl: 1200,
  xxl: 1400
}

Default Image Widths

{
  xs: [320],
  sm: [576],
  md: [768],
  lg: [992],
  xl: [1200],
  xxl: [1400]
}

Performance Tips

  • Use WebP Format: Provide WebP images when possible for better compression
  • Optimize Image Dimensions: Use appropriate image sizes for different breakpoints
  • Enable Optimization: Use the optimize prop for automatic responsive handling
  • Adjust Loading Offset: Set an appropriate offset based on your use case
  • Choose Appropriate Quality: Balance quality and file size with the quality prop

License

MIT © Asfak Ahmed ( rahi )

Keywords

react

FAQs

Package last updated on 17 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts