# @acrool/react-img

> Img with React Component

Latest version **2.0.1** (published 2025-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @acrool/react-img
pnpm add @acrool/react-img
yarn add @acrool/react-img
bun add @acrool/react-img
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2025-07-22 |
| First published | 2024-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14 |
| Dependencies | 2 |
| Unpacked size | 25.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | imagine10255 |
| Keywords | react, typescript, img |

## Links

- npm: https://www.npmjs.com/package/@acrool/react-img
- Repository: https://github.com/acrool/acrool-react-img
- Homepage: https://github.com/acrool/acrool-react-img#readme
- Issues: https://github.com/acrool/acrool-react-img/issues
- npm.io page: https://npm.io/package/@acrool/react-img

## Dependencies (2)

- [clsx](https://npm.io/package/clsx.md) 2.1.1
- [@acrool/react-hooks](https://npm.io/package/@acrool/react-hooks.md) 1.1.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2025-07-22
- 1.1.5-alpha.0 (alpha) — 2025-07-20
- 1.1.4 — 2025-07-19
- 1.1.3 — 2025-05-09
- 1.1.3-alpha.3 — 2025-04-30
- 1.1.3-alpha.2 — 2025-04-30
- 1.1.3-alpha.1 — 2025-04-30
- 1.1.3-alpha.0 — 2025-04-30
- 1.1.2 — 2025-04-28
- 1.1.2-alpha.0 — 2025-04-28
- 1.1.1 — 2025-04-26
- 1.1.1-alpha.1 — 2025-04-26
- 1.1.1-alpha.0 — 2025-04-26
- 1.1.0 — 2025-04-21
- 1.0.3-alpha.0 — 2024-12-09
- … 16 more at https://npm.io/package/@acrool/react-img/versions

## README

# Acrool React Img

<a href="https://acrool-react-img.pages.dev/" title="Acrool React Img - Fast custom img for Reactjs">
    <img src="https://raw.githubusercontent.com/acrool/acrool-react-img/main/example/public/og.webp" alt="Acrool React Img Logo"/>
</a>

<p align="center">
    Fast custom img for Reactjs
</p>

<div align="center">

[![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)

</div>


`^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 <Img
        src="https://acrool-react-picker.pages.dev/sample/1.jpg"
        width={200}
        height={200}
        radius={8}
        isLazy
        isLazyLoaderVisible
    />;
};

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)

---
_Source: https://npm.io/package/@acrool/react-img · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
