emoji-picker-react

repository·master·Indexed 23 days ago

https://github.com/ealush/emoji-picker-react

A highly customizable and responsive emoji picker component for React web applications. It supports multiple emoji styles (Apple, Google, Facebook, Twitter, native), dark mode, internationalization, and custom image-based emojis. Features include a reactions picker mode, skin tone selection, and a searchable interface with configurable categories. Version 4.19.1.

Tokens
3.8K
Snippets
14
Records
36
Agent score
79%

What's inside emoji-picker-react

  1. Use Reactions Picker Mode

    master

    You can transform the picker into a single-row reactions bar using the following props:

    PropTypeDefaultDescription
    reactionsDefaultOpenbooleanfalseIf true, mounts in single-row reaction mode
    reactionsstring[](Default Set)Array of unified IDs to display
    allowExpandReactionsbooleantrueIf true, shows a + button to switch to full picker
  2. Customize Category Icons

    master

    You can customize navigation icons using two methods. If both are used for the same category, the categories configuration takes precedence.

    Method 1: Using the categoryIcons prop Map Categories enum values to React nodes:

    import EmojiPicker, { Categories } from 'emoji-picker-react';
    
    <EmojiPicker
      categoryIcons={{
        [Categories.SUGGESTED]: <img src="recent.png" alt="Recent" />,
        [Categories.SMILEYS_PEOPLE]: <MyCustomFaceIcon />,
      }}
    />;

    Method 2: Using the categories configuration array Define the icon directly within the category object:

    import EmojiPicker, { Categories } from 'emoji-picker-react';
    
    <EmojiPicker
      categories={[
        {
          category: Categories.SUGGESTED,
          name: 'Recently Used',
          icon: <img src="recent.png" alt="Recent" />,
        },
        {
          category: Categories.SMILEYS_PEOPLE,
          name: 'Smileys & People',
          icon: <MyCustomFaceIcon />,
        },
      ]}
    />;
  3. Implement Internationalization (i18n)

    master

    To change the language of the picker, import the desired locale data and pass it to the emojiData prop.

    Example for Spanish:

    import EmojiPicker from 'emoji-picker-react';
    import es from 'emoji-picker-react/dist/data/emojis-es'; // Spanish
    
    function App() {
      return <EmojiPicker emojiData={es} />;
    }
  4. Configure category display with UserCategoryConfig

    master

    When using mergeCategoriesConfig, the userCategoriesConfig parameter (of type UserCategoryConfig) determines the order and content of the category list. It supports two types of entries:

    1. Category Enum: Passing a value from the Categories enum (e.g., Categories.FLAGS) will include that category using its default configuration.
    2. CategoryConfig Object: Passing a custom object allows you to override the name of a specific category. To override an existing category, ensure the category property matches the enum value.

    If userCategoriesConfig is empty or not provided, the picker defaults to the standard ordered list of categories.

  5. Troubleshoot SSR (Next.js / Remix)

    master

    This package requires the window object and cannot be rendered on the server. When using Next.js, use next/dynamic with ssr: false to load the component only on the client.

    import dynamic from 'next/dynamic';
    
    const Picker = dynamic(() => import('emoji-picker-react'), { ssr: false });
  6. Basic Usage of EmojiPicker

    master

    Render the EmojiPicker component in your application. It works immediately with sensible defaults and no required props. You can use the onEmojiClick prop to handle emoji selections.

    import EmojiPicker from 'emoji-picker-react';
    
    function App() {
      return (
        <div>
          <EmojiPicker onEmojiClick={(emojiObject) => console.log(emojiObject)} />
        </div>
      );
    }