1.0.6 • Published 9 months ago

react-image-glow v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

react-image-glow

react-image-glow is a React component that adds a glowing background effect to images, similar to YouTube's ambient mode. It’s lightweight and customizable, letting you control the glow radius, saturation, and opacity for a stunning visual effect.

react-image-glow

Installation

Install the package using npm or yarn:

npm install react-image-glow

or

yarn add react-image-glow

Usage

Wrap any <img>, <motion.img>, or <Image> element with the <ImageGlow> component to apply a glowing effect. You can customize the intensity of the glow with optional props.

Basic Example

import ImageGlow from 'react-image-glow';

<ImageGlow>
  <img src="https://picsum.photos/300" alt="Placeholder" />
</ImageGlow>

Advanced Example with Custom Properties

import ImageGlow from 'react-image-glow';

<ImageGlow
  radius={30}
  saturation={1.5}
  opacity={0.8}
  className="example"
>
  <img
    src="https://picsum.photos/300"
    alt="Placeholder"
    className="max-w-[300px]"
  />
</ImageGlow>

Props

PropTypeDefaultDescription
childrenReactNodeN/AA single <img>, <motion.img>, or <Image> element as its child.
radiusnumber50The radius of the blur effect applied to the background.
saturationnumber2Saturation level for the glowing background. A higher value increases the intensity of colors.
opacitynumber1The opacity of the glowing background (0 = fully transparent, 1 = fully opaque).
classNamestring''An optional class name to apply to the <img> element. Useful for additional styling.

Error Handling

  • ImageGlow expects a single <img>, <motion.img>, or <Image> element as its child. If no child element is present, an error will be logged to the console.

Styling

The component uses inline styles for layout, ensuring the glowing effect aligns perfectly with the image. You can still pass custom styles to the <img> element or apply classes via the className prop for further customization.

How It Works

The ImageGlow component creates two layers: 1. Base Image Layer: The provided <img>, <motion.img>, or <Image> element is displayed with any custom styles or classes. 2. Glow Layer: A blurred, saturated, and optionally semi-transparent version of the image is placed behind the original image to create a glow effect.

This is achieved using CSS properties like filter: blur and saturate to manipulate the image’s background.

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago