npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-inner-image-zoom

v4.0.1

Published

A React component for magnifying an image within its parent container 🔎

Readme

react-inner-image-zoom

GitHub Actions NPM

A lightweight React component for magnifying an image within its original container.

Demos | Changelog

Installation

Note: Version 2.0.0 introduces React hooks and requires React v16.8.0 or above. To use this package with older versions of React, install with npm install [email protected] or yarn add [email protected] instead of the instructions below.

NPM

npm install react-inner-image-zoom

Yarn

yarn add react-inner-image-zoom

TypeScript

Type declarations were added with version 4.0.0. For older installations, type definitions are available through DefinitelyTyped and can be installed with:

npm install --save-dev @types/react-inner-image-zoom

Styling

You can download the raw styles.css file or, if your build supports it, import the stylesheet directly from node_modules using:

import 'react-inner-image-zoom/lib/styles.min.css';

Usage

Import and render the component:

import InnerImageZoom from 'react-inner-image-zoom';

...

<InnerImageZoom src="/path/to/image.jpg" zoomSrc="/path/to/zoom-image.jpg" />

This is the simplest usage. For additional examples, visit the demo page.

Props

Prop | Type | Default | Description --- | --- | --- | --- src | string | | (Required) URL for the original image. sources | array | | A list of image sources for using the picture tag to serve the appropriate original image (see below for more details). width | number | | Width attribute for original image. height | number | | Height attribute for original image. hasSpacer | boolean | false | If true, gets the original image's aspect ratio based on the width and height props and creates a spacer to prevent cumulative layout shift. imgAttributes | object | | Img and global attributes for the original image (excluding src, width, height, and style which are set elsewhere). The imgAttributes keys should follow the React DOM element naming conventions. zoomSrc | string | | URL for the larger zoom image. Falls back to original image src if not defined. zoomScale | number | 1 | Multiplied against the natural width and height of the zoomed image. This will generally be a decimal (example, 0.9 for 90%). zoomPreload | boolean | false | If set to true, preloads the zoom image instead of waiting for mouseenter and (unless on a touch device) persists the image on mouseleave. moveType | pan or drag | pan | The user behavior for moving zoomed images on non-touch devices. zoomType | click or hover | click | The user behavior for triggering zoom. When using hover, combine with zoomPreload to avoid flickering on rapid mouse movements. fadeDuration | number | 150 | Fade transition time in milliseconds. If zooming in on transparent images, set this to 0 for best results. fullscreenOnMobile | boolean | false | Enables fullscreen zoomed image on touch devices below a specified breakpoint. mobileBreakpoint | number | 640 | The maximum breakpoint for fullscreen zoom image when fullscreenOnMobile is true. hideCloseButton | boolean | false | Hides the close button on touch devices. If set to true, zoom out is triggered by tap. hideHint | boolean | false | Hides the magnifying glass hint. className | string | | Custom classname for styling the component. afterZoomIn | () => void | | Function to be called after zoom in. afterZoomOut | () => void | | Function to be called after zoom out.

Ref

The ref prop forwards an object with the container (the root figure element) and portal DOM nodes. portal grants access to the zoomed image on touch devices when fullscreenOnMobile is set and is only available while the image is zoomed. When using with TypeScript, InnerImageZoomRef can be imported to use as a type argument with useRef.

Sources

This prop accepts an array of objects which it uses to create a picture tag and source elements. The component looks for the following optional properties and you can find additional details on responsive images here:

Prop | Type | Default | Description --- | --- | --- | --- srcSet | string | | Srcset attribute for source tag. sizes | string | | Sizes attribute for source tag. media | string | | An attribute containing a media condition for use with the srcset. type | string | | An image MIME type. This is useful for using newer formats like WebP.

Issues

Please submit bugs or requests on the GitHub issues page and make sure to use the react label.

License

MIT