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

https://github.com/jonatanramhoj/react-background-image

Display a placeholder image while the real image loads.
https://github.com/jonatanramhoj/react-background-image

background-image component react react-component typescript

Last synced: 10 months ago
JSON representation

Display a placeholder image while the real image loads.

Awesome Lists containing this project

README

          

# react-background-image

> Display a placeholder image while the real image loads.

[![NPM](https://img.shields.io/npm/v/react-background-image.svg)](https://www.npmjs.com/package/react-background-image) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save react-background-image
```

## Usage

```tsx
import React from 'react';
import BackgroundImage from 'react-background-image';
import placeholder from './images/small.jpg';
import hdImage from './images/large.jpg';

export default function App() {
return (



Other element





);
}
```

## Props

| Prop | Type | Notes |
| ----------- | ------ | --------------------------------------------- |
| src | String | HD image to load |
| placeholder | String | Placeholder image to be immediately displayed |
| className | String | Optional custom css class |

## Demo

https://jonatanramhoj.github.io/react-background-image/

## License

MIT © [jonatanramhoj](https://github.com/jonatanramhoj)