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

https://github.com/gaddafirusli/react-native-image-overlay

React Native's ImageBackground with overlay
https://github.com/gaddafirusli/react-native-image-overlay

image imagebackground react react-native

Last synced: about 1 year ago
JSON representation

React Native's ImageBackground with overlay

Awesome Lists containing this project

README

          


react-native-image-overlay


React Native ImageBackground is useful. But you know what's even more useful?

ImageBackground with overlay. This is exactly it.

![Header image](image/header.png)


[![npm](https://img.shields.io/npm/dt/react-native-image-overlay.svg)](https://www.npmjs.com/package/react-native-image-overlay)

## Get Started

### Installation
```bash
$ npm install --save react-native-image-overlay
```

### Usage
```javascript
import ImageOverlay from "react-native-image-overlay";

export class MyApp extends Component {
render () {
return (
// For external image

// For local asset

)
}
}
```


## Props

| Prop | Description | Type | Default |
| ----------------- | ------------------------------------------------------------------------------------------ | ------------------- | ----------- |
| `blurRadius` | The blur radius of the blur filter added to the image | Number | `undefined` |
| `containerStyle` | Additional styling for the component | ViewStyle | `undefined` |
| `contentPosition` | Position of `title` text or child component (if any). | String (`"top"`,`"center"` or `"bottom"`) | `"center"` |
| `height` | The height of the whole component | Number | `300` |
| `overlayColor` | The color to be used for the overlay on top of the image | String | `"#000000"` |
| `overlayAlpha` | Opacity value of the overlay. From `0` to `1` | Number | `0.5` |
| `rounded` | Value for `borderRadius` to be applied to the component | Number | `undefined` |
| `source` | The image source (either a remote URL or a local file resource). | ImageSource | |
| `title` | Text to be displayed over the image | String | `undefined` |
| `titleStyle` | Additional styling for the title text | TextStyle | `undefined` |


## Example

### 1. Simple overlay color

The most basic use-case of this module is to add colored overlay on top of your image.
```javascript

```
Default overlay is color is `#000000` with `0.5` opacity. You can customize it to any color
```javascript

```
### 2. Overlay with title text

![Title text image](image/titledemo.png)

If you want to display a simple white text on top of the image, you can use the `title` prop.
```javascript

```
The title will be `center`-ed by default. You can move it to the `top` or `bottom` using the `contentPosition` prop
```javascript

```

Additionally, you can change the styling by passing the `titleStyle` along
```javascript

```

### 3. Overlay with child component

![Child component image](image/customdemo.png)

You can pass extra components to be displayed on top of your image.
```javascript



Amelia Edwards
Kuala Lumpur, Malaysia

```
> Note: When you are using child component, `title` prop will be ignored.