react-native-chat-images
Version:
A React Native library to show images grid in chat messages like your favorite platforms!
128 lines (95 loc) • 4.94 kB
Markdown
> A **React Native** library to show images grid in chat messages like your favorite platforms! (WhatsApp, Messenger)
[](https://www.npmjs.com/package/react-native-chat-images)
[](https://www.npmjs.com/package/react-native-chat-images)
<p align="center">
<img alt="react-native-chat-images" src="preview/sample.gif" width="260" height="510" />
</a>
</p>
<h3 align="center">
React Native Chat Images
</h3>
<p align="center">
<img src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=exp://expo.io/@muhammadovi/react-native-chat-images">
<br>
<a href="https://snack.expo.io/@muhammadovi/react-native-chat-images" target="_blank"><i>demo</i> <small> (expo)</small></a>
</p>
You can find the complete changelog [on this file](/ChangeLog.md).
```bash
npm i -S react-native-chat-images
```
OR
```bash
yarn add react-native-chat-images
```

| Props | Type | Default | Example |
| :-------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------: | :------------: | :----------------------------------: |
| [images](
| extra | string | `undefined` | `'03:30 AM'` |
| title | string | `undefined` | `'Title of Images'` |
| style | object | `{}` | |
| backgroundColor | string | `'lightgreen'` | `'red'` <br /> OR <br /> `'#ff0000'` |
| width | string <br /> OR <br /> number | `'100%'` | `'50%'` <br /> OR <br /> `360` |
| saveOnLongPress | bool | `true` | `true` <br /> OR <br /> `false` |
> **\*** if you pass array of objects you may also provide some extra information: see > [Image Props](
```jsx
import React, { Component } from 'react';
import { View } from 'react-native';
import Images from 'react-native-chat-images';
export default class App extends Component {
state = {
images: ['img_01', 'img_02', 'img_03', '...'],
};
render() {
return (
<View style={{ flex: 1 }}>
<Images images={this.state.imgs} />
</View>
);
}
}
```
```jsx
import React, { Component } from 'react';
import { View } from 'react-native';
import Images from 'react-native-chat-images';
export default class App extends Component {
state = {
images: [
{ url: 'img_01' },
{ url: 'img_02' },
{ url: 'img_03' },
{ url: '...' },
],
};
render() {
return (
<View style={{ flex: 1 }}>
<Images images={this.state.images} />
</View>
);
}
}
```
| Props | Type | Required |
| :----------- | :------------------: | :------: |
| url | string (`url`) | **yes** |
| thumbnail | string (`url`) | no |
| caption | string | no |
| captionStyle | object | no |
| overlay | `ReactNativeElement` | no |



MIT © [Ovi](https://github.com/Ovi) | [License](/LICENSE)