Introducing npm Teams! Private packages + team management tools.Learn more »


2.5.2 • Public • Published

Emoji Button

Vanilla JavaScript emoji picker 😎




  • 💻 Vanilla JS, use with any framework
  • 🔎 Emoji search
  • 👍🏼 Skin tone variations
  • ⏱ Recently used emojis


npm install --save @joeattardi/emoji-button

Basic usage

  import EmojiButton from '@joeattardi/emoji-button';
  const button = document.querySelector('#emoji-button');
  const picker = new EmojiButton();
  picker.on('emoji', emoji => {
    document.querySelector('input').value += emoji;
  button.addEventListener('click', () => {
    picker.pickerVisible ? picker.hidePicker() : picker.showPicker(button);


new EmojiButton(options)

Creates an Emoji Button emoji picker.


  • autoHide: (boolean, default: true) Whether or not the picker should automatically be hidden when an emoji is clicked.

  • autoFocusSearch: (boolean, default: true) Whether or not to auto-focus the search field when the picker is shown.

  • position: The position to display the picker relative to the reference element. Valid values are:

    • auto
    • auto-start
    • auto-end
    • top
    • top-start
    • top-end
    • right
    • right-start
    • right-end
    • bottom
    • bottom-start
    • bottom-end
    • left
    • left-start
    • left-end
  • recentsCount: (number, default: 50): The maximum number of recent emojis to save.

  • rootElement: The root DOM node to attach the picker to. Defaults to the body if not passed in.

  • showPreview: (boolean, default: true) Whether or not to show the emoji preview area.

  • showSearch: (boolean, default: true) Whether or not to show the search bar.

  • showRecents: (boolean, default: true) Whether or not to show (and save) recently used emojis.

  • showVariants: (boolean, default: true) Whether or not to show skin tone variants.

  • zIndex: (number): If specified, sets a z-index for the emoji picker container.

  • i18n: An object containing localized messages to display in the UI. The values and their defaults are as follows:

  search: 'Search emojis...',
  categories: {
    recents: 'Recent Emojis',
    smileys: 'Smileys & People',
    animals: 'Animals & Nature',
    food: 'Food & Drink',
    activities: 'Activities',
    travel: 'Travel & Places',
    objects: 'Objects',
    symbols: 'Symbols',
    flags: 'Flags'
  notFound: 'No emojis found'


Shows the picker, positioning it relative to the given reference element. The reference element is usually the button or other element that was clicked to open the picker.


Hides the picker.

pickerVisible (property)

Will be true if the picker is currently visible, and false if not.

on(event, callback)

Adds an event listener. Currently there is only one event:

  • emoji: Fired when an emoji is picked. The callback is called with a single argument, the emoji character that was picked.


The easiest way to hack on Emoji Button is to use the examples page.

Clone the repository

git clone

From the repository root

Install dependencies

npm install

Set up the link

npm link

Start the build/watch loop

npm run build:watch

From the examples subdirectory

Install dependencies

npm install

Link the library

npm link @joeattardi/emoji-button

Start the dev server

npm start

Open the page



npm i @joeattardi/emoji-button

DownloadsWeekly Downloads






Unpacked Size

299 kB

Total Files


Last publish


  • avatar