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

https://github.com/acrool/acrool-react-img

Img library based for Reactjs
https://github.com/acrool/acrool-react-img

image-lazy-load img reactjs

Last synced: 10 months ago
JSON representation

Img library based for Reactjs

Awesome Lists containing this project

README

          

# Acrool React Img


Acrool React Img Logo


Fast custom img for Reactjs

[![NPM](https://img.shields.io/npm/v/@acrool/react-img.svg?style=for-the-badge)](https://www.npmjs.com/package/@acrool/react-img)
[![npm](https://img.shields.io/bundlejs/size/@acrool/react-img?style=for-the-badge)](https://github.com/acrool/@acrool/react-img/blob/main/LICENSE)
[![npm](https://img.shields.io/npm/l/@acrool/react-img?style=for-the-badge)](https://github.com/acrool/react-img/blob/main/LICENSE)

[![npm downloads](https://img.shields.io/npm/dm/@acrool/react-img.svg?style=for-the-badge)](https://www.npmjs.com/package/@acrool/react-img)
[![npm](https://img.shields.io/npm/dt/@acrool/react-img.svg?style=for-the-badge)](https://www.npmjs.com/package/@acrool/react-img)

`^1.1.0 support react >=18.0.0 <20.0.0`

## Features

- Support width, height, aspect
- Support lazy load image
- Support mask animate
- Use native img tag with object-fit for better performance

## Why use img tag instead of background image?

Using the native img tag with object-fit provides better performance and accessibility. It also avoids potential issues with background image layering and provides native image attributes like alt text for better SEO and accessibility.

## Install

```bash
yarn add @acrool/react-img
```

## Usage

add in your index.tsx
```tst
import "@acrool/react-img/dist/index.css";
```

then in your page
```tsx
import {Flex, fr, Grid} from '@acrool/react-grid';
import styled from 'styled-components';

import {Img} from '@acrool/react-img';
import {generatorArray} from '@acrool/js-utils/array';

const Example = () => {
return ;
};

export default Example;

```

There is also a example that you can play with it:

[![Play react-editext-example](https://raw.githubusercontent.com/acrool/acrool-react-img/main/play-in-example-button.svg)](https://acrool-react-img.pages.dev)

## License

MIT © [Acrool](https://github.com/acrool) & [Imagine](https://github.com/imagine10255)