An open API service indexing awesome lists of open source software.

https://github.com/alstonchan/image

A simple React image component
https://github.com/alstonchan/image

image react-component responsive typescript vitejs

Last synced: 3 months ago
JSON representation

A simple React image component

Awesome Lists containing this project

README

          

# React Image Component

A simple, easy to use image component for React. (Compatible with NextJs)

## Installation

```bash
npm install @chan_alston/image@latest --save
```

## `Image` usage

```javascript
import styles from "./image.module.css";

import React from "react";
import Image from "@chan_alston/image";

import myImg from "../public/myImg.jpg";
import myImgSmall from "../public/myImgSmall.jpg";
import myImgMedium from "../public/myImgMedium.jpg";
import myImgBig from "../public/myImgBig.jpg";

const ImageComponent = ({ image }) => (


This is my image

);

export default ImageComponent;
```

### Properties of `Image`

| Properties | Type | Required | Default Value |
|-------------|:-------------------------:|:---------:|:-------------:|
| src | String or StaticImageData | true | |
| alt | String | true | |
| w | String or Number | false | |
| h | String or Number | false | |
| className | String | false | |
| srcSet | String | false | |
| sizes | String | false | |
| responsive | Boolean | false | true |
| priority | Boolean | false | false |
| imgRef | React.MutableRefObject | false | null |
| style | CSSProperties | false | {} |
| placeholder | String or StaticImageData | false | |

### Notes

- When `w`(width) and/or `h`(height) is set, `responsive` is set to **false** by default, unless explicitly specify with `responsive`.