Package Exports
- emoji-picker-react
- emoji-picker-react/dist/emoji-picker-react.esm.js
- emoji-picker-react/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (emoji-picker-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Emoji Picker React (v4)
An emoji picker component for React applications.
What to know before using
- This package assumes it runs in the browser. I have taken many steps to prevent it from failing on the server, but still, it is recommended to only render the component on the client. See troubleshooting section for more information.
Installation
npm install emoji-picker-react
Usage:
import EmojiPicker from 'emoji-picker-react';
function App() {
return (
<div>
<EmojiPicker />
</div>
);
}
Features
- Custom click handler
- Dark mode
- Customizable styles via css variables
- Default skin tone selection
- Skin tone change
- Different emoji sets (Google, Apple, Facebook, Twitter)
- Native Emoji support
Props
The following props are accepted by them picker:
onEmojiClick
:(event: MouseEvent, emoji: EmojiClickData) => void
- Callback function when an emoji is clicked. The callback receives the event and the emoji data. The emoji data is comprised of the following properties:{ activeSkinTone: SkinTones; unified: string; unifiedWithoutSkinTone: string; emoji: string; names: string[]; getImageUrl: (emojiStyle: EmojiStyle) => string; }
theme
:Theme
- The theme of the picker. Can belight
,dark
or auto. Default islight
. TheTheme
enum can be imported from the package.import { Theme } from 'emoji-picker-react';
emojiStyle
:EmojiStyle
- The emoji style to use. Can be eitherapple
,google
,facebook
,twitter
ornative
. Default isapple
. TheEmojiStyle
enum can be imported from the package.import { EmojiStyle } from 'emoji-picker-react';
autoFocusSearch
:boolean
- Whether to focus the search input on mount. Defaults totrue
.defaultSkinTone
:SkinTones
- The default skin tone to use when an emoji is clicked. Defaults toSkinTones.Neutral
. Possible skin tones are:- ✋ 'neutral'
- ✋🏻 '1f3fb'
- ✋🏼 '1f3fc'
- ✋🏽 '1f3fd'
- ✋🏾 '1f3fe'
- ✋🏿 '1f3ff'
The skin tones typescript enum can be imported directly from the package:
import { SkinTones } from 'emoji-picker-react';
skinTonesDisabled
:boolean
- Whether to disable the skin tone selection. Defaults tofalse
.showPreview
:boolean
- Whether to show the preview of the selected emoji. Defaults totrue
.searchPlaceholder
:string
- The placeholder text for the search input. Defaults toSearch
.categories: Allows full config over ordering, naming and display of categories. To only sort/omit categories, you can simply pass an array of category names to display:
- 'recently_used',
- 'smileys_people',
- 'animals_nature',
- 'food_drink',
- 'travel_places',
- 'activities',
- 'objects',
- 'symbols',
- 'flags'
For a more in-depth configuration, you can pass an array with category config:
[ { category: 'recently_used', name: 'Recently Used' }, { category: 'smileys_people', name: 'Faces...' } ];
Troubleshooting
Next.js
To avoid errors such as "document is not defined" on the server side, you should make sure the library is only imported on the client side. Here is how to do that:
import dynamic from 'next/dynamic';
const Picker = dynamic(
() => {
return import('emoji-picker-react');
},
{ ssr: false }
);
Vite
For reference, if you only need to shim global, you can add
<script>
window.global = window;
</script>