Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/pladaria/react-emojione

A tiny library to use emojis in React
https://github.com/pladaria/react-emojione

Last synced: about 1 month ago
JSON representation

A tiny library to use emojis in React

Awesome Lists containing this project

README

        






react-emojione


A tiny library to use emojis in React

## Features

- Updated to emojione v3.1.2
- Dependency free!
- Can be used as function: `emojify()` or component: ``
- Converts :shortnames:, unicode and ASCII smileys
- Copy-paste friendly
- Sprite mode (the only supported mode for now)
- Configurable styles and options
- Easy!

## Demo

[Live demo](https://runkit.com/pladaria/react-emojione)

## Install

```javascript
npm install --save react-emojione
```

## Development / Run demo

```bash
# clone repo
git clone ...

# get dependencies
yarn

# start dev-server
yarn start
```

## Basic usage (function)

```javascript
import {emojify} from 'react-emojione';

ReactDOM.render(


{emojify('Easy! :wink: 😸 :D ^__^')}
,
document.body
);
```

## Basic usage (component)

```javascript
import Emojify from 'react-emojione';

ReactDOM.render(

Easy! :wink:
😸 :D ^__^
,
document.body
);
```

## Advanced usage (function)

```javascript
import {emojify} from 'react-emojione';

const options = {
convertShortnames: true,
convertUnicode: true,
convertAscii: true,
style: {
backgroundImage: 'url("/path/to/your/emojione.sprites.png")',
height: 32,
margin: 4,
},
// this click handler will be set on every emoji
onClick: event => alert(event.target.title)
};

ReactDOM.render(


{emojify('Easy! :wink: 😸 :D ^__^', options)}
,
document.body
);
```

## Advanced usage (component)

Simply pass options as props

```javascript
import Emojify from 'react-emojione';

ReactDOM.render(
alert(e.target.title)}>
Easy! :wink:
😸 :D ^__^
,
document.body
);
```
Some notes about the `` component:
- If it has a single child, it won't be wrapped
- Otherwise it will be wrapped with a ``

## Output

You can also render to unicode (instead of react elements) using the `output` option
```javascript
import {emojify} from 'react-emojione';

emojify('Easy! :wink: :D ^__^', {output: 'unicode'});
// Easy! 😉 😃 😄
```

## License

MIT

---
Emoji provided free by [http://emojione.com](http://emojione.com)