React lightweight stateless component for image zoom on mouse hover.
Designed for e-commerce sites product detail.
npm install --save react-content-zoom
include this css in your project
...
.zoomed-image {
background-size: cover;
cursor: pointer;
}
...
import ContentZoom from 'react-content-zoom';
...
<ContentZoom zoomPercent={350}
largeImageUrl="./static/img.jpg"
imageUrl="./static/img_small.jpg"
contentHeight={300}
contentWidth={500} />
...
You can put some content inside if you need
...
<ContentZoom zoomPercent={350}
largeImageUrl="./static/img.jpg"
imageUrl="./static/img_small.jpg"
contentHeight={300}
contentWidth={500}><h1>Put your content here!</h1></ContentZoom>
...
Support any content inside your image container.
Prop | Type | Required | Default | Description |
---|---|---|---|---|
zoomPercent |
Number | No | 250 | Small image url |
largeImageUrl |
String | Yes | Large image url | |
imageUrl |
String | Yes | Small image url | |
contentWidth |
Number | No | 100% | Style applied to image container |
contentHeight |
Number | No | 100% | Style applied to image container |
Please open an issue.
git clone https://github.com/eubash/react-content-zoom.git
cd react-content-zoom
npm install
npm run #See available commands
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
MIT