React Emoji Picker

4.18.0 · active · verified Sun Apr 19

emoji-picker-react is a popular, actively maintained React component library providing a fully customizable emoji picker for web applications. The current stable version is 4.18.0. The library receives regular updates, including significant breaking changes in major versions like 2.0.0 and 4.0.0 that refined its UI and customization model. Key differentiators include extensive customization options via CSS variables, native dark mode support, multi-language capabilities, support for custom image-based emojis, and a responsive, zero-configuration setup with various emoji styles (Apple, Google, etc.). It aims to be an out-of-the-box solution with sensible defaults while offering deep control for specific use cases.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to render the EmojiPicker component, handle emoji selection, toggle its visibility, and customize its appearance with theme and emoji style options.

import React, { useState } from 'react';
import EmojiPicker, { EmojiClickData, Theme, EmojiStyle } from 'emoji-picker-react';

function App() {
  const [selectedEmoji, setSelectedEmoji] = useState<string>('');
  const [showPicker, setShowPicker] = useState<boolean>(false);

  const onEmojiClick = (emojiObject: EmojiClickData, event: MouseEvent) => {
    setSelectedEmoji(emojiObject.emoji);
    setShowPicker(false); // Close picker after selection
    console.log("Selected emoji data:", emojiObject);
    console.log("Event:", event);
  };

  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', padding: '20px' }}>
      <h1>Emoji Picker React Example</h1>
      <button onClick={() => setShowPicker(!showPicker)} style={{ marginBottom: '20px', padding: '10px 20px' }}>
        {showPicker ? 'Hide Emoji Picker' : 'Show Emoji Picker'}
      </button>
      {selectedEmoji && <p style={{ fontSize: '2em' }}>You selected: {selectedEmoji}</p>}

      {showPicker && (
        <EmojiPicker
          onEmojiClick={onEmojiClick}
          theme={Theme.AUTO} // Use auto theme based on system preference
          emojiStyle={EmojiStyle.APPLE} // Prefer Apple style emojis
          lazyLoadEmojis={true} // Load emojis on scroll
          autoFocusSearch={true}
          width="100%"
          height={400}
        />
      )}
    </div>
  );
}

export default App;

view raw JSON →