Convert Figma logo to code with AI

missive logoemoji-mart

šŸŖ One component to pick them all

8,537
821
8,537
156

Top Related Projects

Easy to parse data and spritesheets for emoji

16,781

Emoji for everyone. https://twemoji.twitter.com/

[Archived] The world's largest independent emoji font. Maintained at https://github.com/joypixels/emoji-toolkit.

2,235

:love_letter: Find the emoji that echoes your mind.

Quick Overview

Emoji Mart is a customizable emoji picker component for web applications. It provides a user-friendly interface for selecting emojis, with support for various datasets, themes, and customization options. The library is designed to be lightweight and easy to integrate into different frameworks and projects.

Pros

  • Highly customizable with options for themes, sets, and custom emojis
  • Supports multiple frameworks including React, Vue, and vanilla JavaScript
  • Offers a lightweight and performant solution for emoji selection
  • Includes search functionality and category navigation for easy emoji discovery

Cons

  • May require additional setup for certain frameworks or build systems
  • Limited built-in internationalization support
  • Some users report occasional performance issues with large datasets
  • Documentation could be more comprehensive for advanced use cases

Code Examples

  1. Basic React implementation:
import { Picker } from 'emoji-mart'

function EmojiPicker() {
  return <Picker onEmojiSelect={console.log} />
}
  1. Custom theme and set in Vue:
<template>
  <Picker
    :theme="'dark'"
    :set="'apple'"
    @select="handleSelect"
  />
</template>

<script>
import { Picker } from 'emoji-mart-vue-fast'

export default {
  components: { Picker },
  methods: {
    handleSelect(emoji) {
      console.log(emoji)
    }
  }
}
</script>
  1. Using custom emojis in vanilla JavaScript:
import { init, Picker } from 'emoji-mart'

init({ custom: [
  {
    id: 'myCoolEmoji',
    name: 'My Cool Emoji',
    keywords: ['cool', 'custom'],
    skins: [{ src: './path-to-emoji.png' }]
  }
]}).then(() => {
  const picker = new Picker({ custom: true })
  document.body.appendChild(picker)
})

Getting Started

To use Emoji Mart in your project, follow these steps:

  1. Install the package:

    npm install emoji-mart
    
  2. Import and use the component in your application:

    import { Picker } from 'emoji-mart'
    import 'emoji-mart/css/emoji-mart.css'
    
    function App() {
      return (
        <Picker
          onEmojiSelect={(emoji) => console.log(emoji)}
          title="Pick your emojiā€¦"
        />
      )
    }
    
  3. Customize as needed using the available props and options.

Competitor Comparisons

Easy to parse data and spritesheets for emoji

Pros of emoji-data

  • Comprehensive emoji dataset with extensive metadata
  • Regular updates to include new emoji releases
  • Provides raw data in multiple formats (JSON, CSV, etc.)

Cons of emoji-data

  • Lacks built-in UI components for emoji selection
  • Requires additional implementation for search and filtering
  • No out-of-the-box support for customization or theming

Code Comparison

emoji-data (JSON format):

{
  "name": "GRINNING FACE",
  "unified": "1F600",
  "non_qualified": null,
  "docomo": null,
  "au": "E471",
  "softbank": "E057",
  "google": "FE332",
  "image": "1f600.png",
  "sheet_x": 30,
  "sheet_y": 24,
  "short_name": "grinning",
  "short_names": ["grinning"],
  "text": null,
  "texts": null,
  "category": "Smileys & Emotion",
  "subcategory": "face-smiling",
  "sort_order": 1,
  "added_in": "6.0",
  "has_img_apple": true,
  "has_img_google": true,
  "has_img_twitter": true,
  "has_img_facebook": true
}

emoji-mart (React component):

import { Picker } from 'emoji-mart'

<Picker
  onSelect={emoji => console.log(emoji)}
  title="Pick your emojiā€¦"
  emoji="point_up"
  style={{ width: '100%' }}
/>

emoji-mart provides a ready-to-use UI component for emoji selection, while emoji-data offers raw data that can be used to build custom implementations. emoji-mart is more suitable for quick integration, whereas emoji-data allows for more flexibility in data usage and custom UI development.

16,781

Emoji for everyone. https://twemoji.twitter.com/

Pros of Twemoji

  • Comprehensive emoji set with consistent design across platforms
  • Lightweight and easy to integrate into web projects
  • Open-source and freely available for commercial use

Cons of Twemoji

  • Limited customization options for emoji appearance
  • Lacks built-in picker or search functionality
  • Requires additional implementation for advanced features

Code Comparison

Twemoji usage:

import twemoji from 'twemoji';

const element = document.getElementById('myElement');
twemoji.parse(element);

Emoji Mart usage:

import { Picker } from 'emoji-mart';

<Picker set="apple" onSelect={this.addEmoji} />

Key Differences

Twemoji focuses on providing a consistent set of emoji images, while Emoji Mart offers a full-featured emoji picker component. Twemoji is more suitable for basic emoji rendering, whereas Emoji Mart excels in interactive emoji selection interfaces.

Twemoji is primarily used for displaying emojis, while Emoji Mart provides a complete solution for emoji picking, including search, categories, and customization options.

Twemoji has broader platform support and is widely used across various projects, including Twitter itself. Emoji Mart is more specialized for applications requiring advanced emoji selection functionality.

[Archived] The world's largest independent emoji font. Maintained at https://github.com/joypixels/emoji-toolkit.

Pros of EmojiOne

  • Offers a comprehensive set of emoji assets, including high-quality PNG and SVG images
  • Provides a wider range of emoji-related tools and resources, including a picker and API
  • Supports multiple platforms and frameworks, including web, mobile, and desktop applications

Cons of EmojiOne

  • Requires a commercial license for many use cases, which may be cost-prohibitive for some projects
  • Has a larger file size and potentially higher resource usage due to its comprehensive nature
  • May have a steeper learning curve for integration compared to Emoji Mart's simpler approach

Code Comparison

EmojiOne:

import { emojione } from 'emojione';

const emojiHtml = emojione.toImage(':smile:');

Emoji Mart:

import { Emoji } from 'emoji-mart';

const emojiComponent = <Emoji emoji=":smile:" set="apple" size={24} />;

Both libraries offer ways to render emojis, but EmojiOne focuses on converting text to emoji images, while Emoji Mart provides a React component for rendering emojis with various customization options.

2,235

:love_letter: Find the emoji that echoes your mind.

Pros of emoji

  • Lightweight and simple implementation
  • Easy to integrate into existing projects
  • Minimal dependencies

Cons of emoji

  • Limited customization options
  • Fewer features compared to emoji-mart
  • Less active development and community support

Code Comparison

emoji-mart:

import { Picker } from 'emoji-mart'

<Picker set='apple' onSelect={this.addEmoji} />

emoji:

import emoji from 'emoji'

emoji.replace_colons(':heart:') // ā¤ļø

emoji-mart offers a more comprehensive picker component with various customization options, while emoji provides a simpler API for basic emoji operations.

emoji-mart includes features like search, recent emojis, and custom categories, making it more suitable for complex applications. On the other hand, emoji is more lightweight and easier to integrate for basic emoji functionality.

emoji-mart has a larger file size and more dependencies, which may impact performance in some cases. emoji is more compact and has minimal dependencies, making it a good choice for projects with simpler requirements.

Overall, the choice between these libraries depends on the specific needs of your project, balancing features and complexity against simplicity and performance.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README


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

NPM DownloadsLast 30 Days