emoji-mart vs emoji-picker-react vs react-emoji-render
Emoji Picker and Rendering Libraries
emoji-martemoji-picker-reactreact-emoji-render

Emoji Picker and Rendering Libraries

Emoji picker and rendering libraries in React provide components and tools for integrating emojis into web applications. These libraries offer features like emoji selection, rendering, and customization, enhancing user interaction and communication. They are particularly useful in chat applications, social media platforms, and any web app that benefits from expressive visual communication. emoji-mart is a highly customizable emoji picker with a rich set of features, emoji-picker-react offers a simple and easy-to-use emoji picker component, and react-emoji-render focuses on rendering emojis from text with support for various formats.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
emoji-mart09,3551.63 MB2132 years agoMIT
emoji-picker-react01,38434.3 MB552 months agoMIT
react-emoji-render0337140 kB143 years agoMIT

Feature Comparison: emoji-mart vs emoji-picker-react vs react-emoji-render

Customization

  • emoji-mart:

    emoji-mart provides extensive customization options, including the ability to customize the emoji pickerโ€™s appearance, categories, and even add your own emojis. It supports theming and allows for deep customization, making it a great choice for applications that need a tailored emoji picker experience.

  • emoji-picker-react:

    emoji-picker-react offers basic customization features, such as changing the pickerโ€™s position, size, and colors. However, it is more limited compared to emoji-mart, making it better suited for applications that need a simple picker with minimal configuration.

  • react-emoji-render:

    react-emoji-render focuses on rendering emojis rather than providing a picker. It allows for customization of emoji rendering, including the ability to use custom emoji sets and control the size and style of rendered emojis. This makes it ideal for applications that need to display emojis in a specific way.

Ease of Integration

  • emoji-mart:

    emoji-mart is relatively easy to integrate but may require more setup time due to its extensive features and customization options. It is well-documented, making it easier for developers to implement and customize.

  • emoji-picker-react:

    emoji-picker-react is designed for quick and easy integration, with a simple API and minimal setup required. It is ideal for projects that need to add emoji picking functionality quickly without a lot of overhead.

  • react-emoji-render:

    react-emoji-render is straightforward to integrate for rendering emojis in text. It provides simple components for rendering emojis from various formats, making it easy to use in any React application.

Performance

  • emoji-mart:

    emoji-mart is feature-rich, which can impact performance if not optimized, especially in applications with limited resources. However, its modular design allows developers to load only the parts they need, which can help mitigate performance issues.

  • emoji-picker-react:

    emoji-picker-react is lightweight and designed for performance, making it a good choice for applications where load time and responsiveness are critical. Its simplicity ensures that it does not add significant overhead to the application.

  • react-emoji-render:

    react-emoji-render is optimized for rendering emojis efficiently, making it suitable for applications that need to display a large number of emojis without impacting performance. Its lightweight nature ensures fast rendering.

Feature Set

  • emoji-mart:

    emoji-mart offers a comprehensive feature set, including emoji search, categories, recent emojis, and the ability to add custom emojis. It is one of the most feature-rich emoji pickers available, making it ideal for applications that need advanced emoji selection capabilities.

  • emoji-picker-react:

    emoji-picker-react provides essential features like emoji categories, search, and recent emojis, but it is more limited compared to emoji-mart. It is suitable for applications that need a basic emoji picker without advanced features.

  • react-emoji-render:

    react-emoji-render focuses on rendering emojis from text rather than providing a picker. It supports multiple emoji formats, including Unicode, shortcodes, and custom emojis, making it versatile for displaying emojis in various contexts.

Code Examples

  • emoji-mart:

    emoji-mart Example

    import { Picker } from 'emoji-mart';
    import 'emoji-mart/css/emoji-mart.css';
    
    function EmojiPicker() {
      return <Picker onSelect={emoji => console.log(emoji)} />;
    }
    
  • emoji-picker-react:

    emoji-picker-react Example

    import EmojiPicker from 'emoji-picker-react';
    
    function EmojiPickerComponent() {
      const onEmojiClick = (event, emojiObject) => {
        console.log(emojiObject);
      };
    
      return <EmojiPicker onEmojiClick={onEmojiClick} />;
    }
    
  • react-emoji-render:

    react-emoji-render Example

    import { Emoji } from 'react-emoji-render';
    
    function EmojiRenderer() {
      return <Emoji text='Hello :smile:' />;
    }
    

How to Choose: emoji-mart vs emoji-picker-react vs react-emoji-render

  • emoji-mart:

    Choose emoji-mart if you need a feature-rich and highly customizable emoji picker with support for multiple themes, categories, and search functionality. It is ideal for applications that require a comprehensive emoji selection experience.

  • emoji-picker-react:

    Choose emoji-picker-react if you want a lightweight and easy-to-integrate emoji picker with a simple API. It is suitable for projects that need a quick and straightforward emoji picker without extensive customization.

  • react-emoji-render:

    Choose react-emoji-render if your primary need is to render emojis from text, including support for Unicode, shortcodes, and custom emoji sets. It is perfect for applications that need to display emojis in chat messages, comments, or any text content.

README for emoji-mart


Emoji Mart is a customizable
emoji picker HTML component for the web
Demo

EmojiMart

Missive | Team email, team chat, team tasks, one app
Brought to you by the Missive team

๐Ÿ“– Table of Contents

๐Ÿ’พ Data

Data required for the picker to work has been completely decoupled from the library. That gives developers the flexibility to better control their app bundle size and let them choose how and when this data is loaded. Data can be:

Bundled directly into your codebase

  • Pros: Picker renders instantly, data is available offline
  • Cons: Slower initial page load (bigger file to load)
yarn add @emoji-mart/data
import data from '@emoji-mart/data'
import { Picker } from 'emoji-mart'

new Picker({ data })

Fetched remotely

  • Pros: Data fetched only when needed, does not affect your app bundle size
  • Cons: Network latency, doesnโ€™t work offline (unless you configure a ServiceWorker)
import { Picker } from 'emoji-mart'
new Picker({
  data: async () => {
    const response = await fetch(
      'https://cdn.jsdelivr.net/npm/@emoji-mart/data',
    )

    return response.json()
  }
})

In this example data is fetched from a content delivery network, but it could also be fetched from your own domain if you want to host the data.

๐Ÿช Picker

React

npm install --save emoji-mart @emoji-mart/data @emoji-mart/react
import data from '@emoji-mart/data'
import Picker from '@emoji-mart/react'

function App() {
  return (
    <Picker data={data} onEmojiSelect={console.log} />
  )
}

Browser

<script src="https://cdn.jsdelivr.net/npm/emoji-mart@latest/dist/browser.js"></script>
<script>
  const pickerOptions = { onEmojiSelect: console.log }
  const picker = new EmojiMart.Picker(pickerOptions)

  document.body.appendChild(picker)
</script>

Options / Props

OptionDefaultChoicesDescription
data{}Data to use for the picker
i18n{}Localization data to use for the picker
categories[]frequent, people, nature, foods, activity, places, objects, symbols, flagsCategories to show in the picker. Order is respected.
custom[]Custom emojis
onEmojiSelectnullCallback when an emoji is selected
onClickOutsidenullCallback when a click outside of the picker happens
onAddCustomEmojinullCallback when the Add custom emoji button is clicked. The button will only be displayed if this callback is provided. It is displayed when search returns no results.
autoFocusfalseWhether the picker should automatically focus on the search input
categoryIcons{}Custom category icons
dynamicWidthfalseWhether the picker should calculate perLine dynamically based on the width of <em-emoji-picker>. When enabled, perLine is ignored
emojiButtonColors[]i.e. #f00, pink, rgba(155,223,88,.7)An array of color that affects the hover background color
emojiButtonRadius100%i.e. 6px, 1em, 100%The radius of the emoji buttons
emojiButtonSize36The size of the emoji buttons
emojiSize24The size of the emojis (inside the buttons)
emojiVersion141, 2, 3, 4, 5, 11, 12, 12.1, 13, 13.1, 14The version of the emoji data to use. Latest version supported in @emoji-mart/data is currently 14
exceptEmojis[]List of emoji IDs that will be excluded from the picker
iconsautoauto, outline, solidThe type of icons to use for the picker. outline with light theme and solid with dark theme.
localeenen, ar, be, cs, de, es, fa, fi, fr, hi, it, ja, ko, nl, pl, pt, ru, sa, tr, uk, vi, zhThe locale to use for the picker
maxFrequentRows4The maximum number of frequent rows to show. 0 will disable frequent category
navPositiontoptop, bottom, noneThe position of the navigation bar
noCountryFlagsfalseWhether to show country flags or not. If not provided, tbhis is handled automatically (Windows doesnโ€™t support country flags)
noResultsEmojicryThe id of the emoji to use for the no results emoji
perLine9The number of emojis to show per line
previewEmojipoint_upThe id of the emoji to use for the preview when not hovering any emoji. point_up when preview position is bottom and point_down when preview position is top.
previewPositionbottomtop, bottom, noneThe position of the preview
searchPositionstickysticky, static, noneThe position of the search input
setnativenative, apple, facebook, google, twitterThe set of emojis to use for the picker. native being the most performant, others rely on spritesheets.
skin11, 2, 3, 4, 5, 6The emojis skin tone
skinTonePositionpreviewpreview, search, noneThe position of the skin tone selector
themeautoauto, light, darkThe color theme of the picker
getSpritesheetURLnullA function that returns the URL of the spritesheet to use for the picker. It should be compatible with the data provided.

Custom emojis

You can use custom emojis by providing an array of categories and their emojis. Emojis also support multiple skin tones and can be GIFs or SVGs.

import data from '@emoji-mart/data'
import Picker from '@emoji-mart/react'

const custom = [
  {
    id: 'github',
    name: 'GitHub',
    emojis: [
      {
        id: 'octocat',
        name: 'Octocat',
        keywords: ['github'],
        skins: [{ src: './octocat.png' }],
      },
      {
        id: 'shipit',
        name: 'Squirrel',
        keywords: ['github'],
        skins: [
          { src: './shipit-1.png' }, { src: './shipit-2.png' }, { src: './shipit-3.png' },
          { src: './shipit-4.png' }, { src: './shipit-5.png' }, { src: './shipit-6.png' },
        ],
      },
    ],
  },
  {
    id: 'gifs',
    name: 'GIFs',
    emojis: [
      {
        id: 'party_parrot',
        name: 'Party Parrot',
        keywords: ['dance', 'dancing'],
        skins: [{ src: './party_parrot.gif' }],
      },
    ],
  },
]

function App() {
  return (
    <Picker data={data} custom={custom} />
  )
}

Custom category icons

You can use custom category icons by providing an object with the category name as key and the icon as value. Currently supported formats are svg string and src. See example.

const customCategoryIcons = {
  categoryIcons: {
    activity: {
      svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M57.89 397.2c-6.262-8.616-16.02-13.19-25.92-13.19c-23.33 0-31.98 20.68-31.98 32.03c0 6.522 1.987 13.1 6.115 18.78l46.52 64C58.89 507.4 68.64 512 78.55 512c23.29 0 31.97-20.66 31.97-32.03c0-6.522-1.988-13.1-6.115-18.78L57.89 397.2zM496.1 352c-44.13 0-79.72 35.75-79.72 80s35.59 80 79.72 80s79.91-35.75 79.91-80S540.2 352 496.1 352zM640 99.38c0-13.61-4.133-27.34-12.72-39.2l-23.63-32.5c-13.44-18.5-33.77-27.68-54.12-27.68c-13.89 0-27.79 4.281-39.51 12.8L307.8 159.7C262.2 192.8 220.4 230.9 183.4 273.4c-24.22 27.88-59.18 63.99-103.5 99.63l56.34 77.52c53.79-35.39 99.15-55.3 127.1-67.27c51.88-22 101.3-49.87 146.9-82.1l202.3-146.7C630.5 140.4 640 120 640 99.38z"/></svg>',
    },
    people: {
      src: './people.png',
    },
  },
}

๐Ÿ™ƒ Emoji component

The emoji web component usage is the same no matter what library you use.

First, you need to make sure data has been initialized. You need to call this only once per page load. Note that if you call init like this, you donโ€™t necessarily need to include data in your Picker props. It doesnโ€™t hurt either, it will noop.

import data from '@emoji-mart/data'
import { init } from 'emoji-mart'

init({ data })

Then you can use the emoji component in your HTML / JSX.

<em-emoji id="+1" size="2em"></em-emoji>
<em-emoji id="+1" skin="2"></em-emoji>
<em-emoji shortcodes=":+1::skin-tone-1:"></em-emoji>
<em-emoji shortcodes=":+1::skin-tone-2:"></em-emoji>

Attributes / Props

AttributeExampleDescription
id+1An emoji ID
shortcodes:+1::skin-tone-2:An emoji shortcode
native๐Ÿ‘A native emoji
size2emThe inline element size
fallback:shrug:A string to be rendered in case the emoji canโ€™t be found
setnativeThe emoji set: native, apple, facebook, google, twitter
skin1The emoji skin tone: 1, 2, 3, 4, 5, 6

๐Ÿ•ต๏ธโ€โ™€๏ธ Headless search

You can search without the Picker. Just like the emoji component, data needs to be initialized first in order to use the search index.

import data from '@emoji-mart/data'
import { init, SearchIndex } from 'emoji-mart'

init({ data })

async function search(value) {
  const emojis = await SearchIndex.search(value)
  const results = emojis.map((emoji) => {
    return emoji.skins[0].native
  })

  console.log(results)
}

search('christmas') // => ['๐ŸŽ„', '๐Ÿ‡จ๐Ÿ‡ฝ', '๐Ÿง‘โ€๐ŸŽ„', '๐Ÿ””', '๐Ÿคถ', '๐ŸŽ', 'โ˜ƒ๏ธ', 'โ„๏ธ', '๐ŸŽ…', 'โ›„']

๐Ÿ”ฌ Get emoji data from native

You can get emoji data from a native emoji. This is useful if you want to get the emoji ID from a native emoji. Just like the emoji component, data needs to be initialized first in order to retrieve the emoji data.

import data from '@emoji-mart/data'
import { init, getEmojiDataFromNative } from 'emoji-mart'

init({ data })

getEmojiDataFromNative('๐Ÿคž๐Ÿฟ').then(console.log)
/* {
  aliases: ['hand_with_index_and_middle_fingers_crossed'],
  id: 'crossed_fingers',
  keywords: ['hand', 'with', 'index', 'and', 'middle', 'good', 'lucky'],
  name: 'Crossed Fingers',
  native: '๐Ÿคž๐Ÿฟ',
  shortcodes: ':crossed_fingers::skin-tone-6:',
  skin: 6,
  unified: '1f91e-1f3ff',
} */

๐Ÿ—บ Internationalization

EmojiMart UI supports multiple languages, feel free to open a PR if yours is missing.

import i18n from '@emoji-mart/data/i18n/fr.json'
i18n.search_no_results_1 = 'Aucun emoji'

new Picker({ i18n })

Given the small file size, English is built-in and doesnโ€™t need to be provided.

๐Ÿ“š Examples

๐Ÿค“ Built for modern browsers

EmojiMart relies on these APIs, you may need to include polyfills if you need to support older browsers:

๐Ÿ›  Development

yarn install
yarn dev