All Projects → tommoor → React Emoji Render

tommoor / React Emoji Render

Licence: mit
Normalize and render emoji's the way your users expect.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Emoji Render

Virtual List
🧾 React Virtual List Component which worked with animation
Stars: ✭ 232 (-7.2%)
Mutual labels:  react-component
Boundless
✨ accessible, battle-tested React components with infinite composability
Stars: ✭ 242 (-3.2%)
Mutual labels:  react-component
Emojibase
🎮 A collection of lightweight, up-to-date, pre-generated, specification compliant, localized emoji JSON datasets, regex patterns, and more.
Stars: ✭ 248 (-0.8%)
Mutual labels:  emoji
React Image Gallery
React carousel image gallery component with thumbnail support 🖼
Stars: ✭ 2,946 (+1078.4%)
Mutual labels:  react-component
React Css Grid
React layout component based on CSS Grid Layout and built with styled-components
Stars: ✭ 239 (-4.4%)
Mutual labels:  react-component
Sweetalert React
Declarative SweetAlert in React
Stars: ✭ 244 (-2.4%)
Mutual labels:  react-component
Java China
🍡 此项目已废弃,请移步至 https://github.com/junicorn/roo
Stars: ✭ 232 (-7.2%)
Mutual labels:  emoji
React Powerplug
🔌 Renderless Containers
Stars: ✭ 2,704 (+981.6%)
Mutual labels:  react-component
Emoji Selector For Gnome
This extension provide a popup menu with some emojis ; clicking on an emoji copies it to the clipboard.
Stars: ✭ 239 (-4.4%)
Mutual labels:  emoji
Java Emoji Converter
Emoji转换工具,便于各种类型的客户端生成的Emoji字符串转换成另外一种格式
Stars: ✭ 249 (-0.4%)
Mutual labels:  emoji
React Sight
Visualization tool for React, with support for Fiber, Router (v4), and Redux
Stars: ✭ 2,716 (+986.4%)
Mutual labels:  react-component
React Sweet Progress
A way to quickly add a progress bar to react app 🌈
Stars: ✭ 239 (-4.4%)
Mutual labels:  react-component
React Email Editor
Drag-n-Drop Email Editor Component for React.js
Stars: ✭ 3,131 (+1152.4%)
Mutual labels:  react-component
React Tater
A React component to add annotations to any element on a page 🥔
Stars: ✭ 235 (-6%)
Mutual labels:  emoji
Gitmoji Changelog
A changelog generator for gitmoji 😜
Stars: ✭ 250 (+0%)
Mutual labels:  emoji
V Emoji Picker
🌟 A Lightweight and customizable package of Emoji Picker in Vue using emojis natives (unicode).
Stars: ✭ 231 (-7.6%)
Mutual labels:  emoji
Base100
base💯 - Encode your data into emoji
Stars: ✭ 244 (-2.4%)
Mutual labels:  emoji
Emoji
🚀 Find the emoji(Unicode)
Stars: ✭ 250 (+0%)
Mutual labels:  emoji
Console Dot Emoji
🍕 Custom Console Logging with Emoji
Stars: ✭ 251 (+0.4%)
Mutual labels:  emoji
Typography
C# Font Reader (TrueType / OpenType / OpenFont / CFF / woff / woff2) , Glyphs Layout and Rendering
Stars: ✭ 246 (-1.6%)
Mutual labels:  emoji

npm version Node.js CI

react-emoji-render

Normalize and render emoji's the way your users expect.

  • Supports unicode emoji characters
  • Supports emoticons such as :) :x :/
  • Supports slack-style emoji names such as 😄
  • Choose between native, twemoji, emojione or custom image sets.
  • Add custom styles when text contains only emoji (to make it bigger, of course)

Live Demo on CodeSandbox

Installation

Install with your favorite package manager:

npm install react-emoji-render --save
yarn add react-emoji-render

Basic Usage

By default the component will normalize all of the different emoji notations to native unicode characters.

import Emoji from "react-emoji-render";

<Emoji text="This ❤️ sentence includes 👍 a variety of emoji types :)" />;

Twemoji

Twemoji is an emoji set designed by Twitter, you can use the included Twemoji component to render emoji images in this style.

import { Twemoji } from 'react-emoji-render';

<Twemoji text="This ❤️ sentence includes 👍 a variety of emoji types :)" />

// or, for svg images:
<Twemoji svg text="This ❤️ sentence includes 👍 a variety of emoji types :)" />

Emojione

Emojione is a great looking open source emoji set, you can use the included Emojione component to render emoji images in this style.

import { Emojione } from 'react-emoji-render';

<Emojione text="This ❤️ sentence includes 👍 a variety of emoji types :)" />

// or, for svg images:
<Emojione svg text="This ❤️ sentence includes 👍 a variety of emoji types :)" />

// or, for Emojione v4
<EmojioneV4 text="This ❤️ sentence includes 👍 a variety of emoji types :)" />
// note: only png supported -->
// https://github.com/emojione/emojione-assets/issues/2

// in v4 size prop can be set at 32, 64 (default) or 128
<EmojioneV4 size={32} text="This ❤️ sentence includes 👍 a variety of emoji types :)" />

Advanced Usage

Only Emoji

The className passed as the onlyEmojiClassName prop is added when the provided text contains only three or less emoji characters. This allows you to add custom styles in this scenario. For example:

<Emoji text="👍" onlyEmojiClassName="make-emojis-large" />

Array Output

If you want to do further processing on the output, for example parsing HTML then it may be useful to not have the normalized emojis be wrapped in a component.

import { toArray } from "react-emoji-render";

// content is an array of text and emoji components, you can now loop through this
// array and perform further processing. Avoid using `dangerouslySetInnerHTML`!
const content = toArray(
  "This ❤️ sentence includes 👍 a variety of emoji types :)"
);

Then, for example, you can parse all the text and emojis in a single string like the following:

const parseEmojis = value => {
  const emojisArray = toArray(value);

  // toArray outputs React elements for emojis and strings for other
  const newValue = emojisArray.reduce((previous, current) => {
    if (typeof current === "string") {
      return previous + current;
    }
    return previous + current.props.children;
  }, "");

  return newValue;
};

parseEmojis(":)hello"); // => "😃hello"

Custom Images

If you wish to use a custom emoji set / location then you can pass options into the props. One way to achive this is to create a wrapping component which provides your options and exposes a new component, something like:

import Emoji from "react-emoji-render";

function MyEmojiRenderer({ children, ...rest }) {
  const options = {
    baseUrl: "https://mycustom.cdn.com/emojis/",
    ext: "svg",
  };

  return <Emoji options={options} {...rest} />;
}

You can then use the new component:

<MyEmojiRenderer text="This ❤️ sentence includes 👍 a variety of emoji types :)" />

Contributing

Emojis and aliases

If our dataset is missing some emoji, please open an issue specifying which one is missing. The library has a package script (yarn update-aliases) that makes it easy to update with the latest emojis at any time. You can directly do it yourself and open a PR as well.

If you would like to add a new alias to an existing emoji, please find the emoji in our custom aliases file and add the alias to its array of aliases. If you have found a source of aliases that is being actively maintained and you would like to add it, please open an issue to discuss it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].