rn-emoji-keyboard
rn-emoji-keyboard copied to clipboard
Super performant, lightweight, fully customizable emoji picker 🚀
🚀 rn-emoji-keyboard
A lightweight, fully customizable emoji picker, written as React Native component (without native elements). Designated to be user and developer friendly! 💖
🪄 Installation
yarn add rn-emoji-keyboard
or
npm install rn-emoji-keyboard
⚡️ Usage
import EmojiPicker from 'rn-emoji-keyboard';
export default function App() {
const [isOpen, setIsOpen] = React.useState<boolean>(false);
const handlePick = (emojiObject: EmojiType) => {
console.log(emojiObject);
/* example emojiObject = {
"emoji": "❤️",
"name": "red heart",
"slug": "red_heart",
"unicode_version": "0.6",
}
*/
};
return (
<EmojiPicker
onEmojiSelected={handlePick}
open={isOpen}
onClose={() => setIsOpen(false)} />
)
}
⚙️ Accepted props (current implemented)
Name | Type | Default Value | Required | Description |
---|---|---|---|---|
onEmojiSelected | function | undefined | yes | Callback on emoji selected |
open | boolean | false | yes | Opens modal picker |
onClose | function | undefined | yes | Request close modal runs when onEmojiSelected or backdrop pressed |
emojiSize | number | 28 | no | Custom emoji size |
enableRecentlyUsed | boolean | false | no | Enable recently used emojis in categories |
categoryPosition | 'floating' | 'top' | 'bottom' | 'floating' | no | Specify category container position |
enableSearchBar | boolean | false | no | Enable search bar |
hideHeader | boolean | false | no | Hide category names |
allowMultipleSelections | boolean | false | no | Allow selecting multiple emoji without dismissing keyboard |
expandable | boolean | true | no | Show knob and enable expand on swipe up |
defaultHeight | number | string | "40%" | no | Specify collapsed container height (number is points, string is a percentage of the screen height) |
expandedHeight | number | string | "80%" | no | Specify expanded container height (number is points, string is a percentage of the screen height) works only if expandable is true |
onCategoryChangeFailed | function | warn(info) | no | Callback on category change failed (info: {index, highestMeasuredFrameIndex, averageItemLength}) |
translation | CategoryTranslation | en | no | Translation object see translation section |
disabledCategories | CategoryTypes[] | [] | no | Hide categories by passing their slugs |
categoryOrder | CategoryTypes[] | [] | no | Set category sequence |
onRequestClose | function | undefined | no | Handle onRequestClose in modal |
disableSafeArea | boolean | false | no | Disable safe area inside modal |
theme | Theme | defaultTheme | no | Custom colors theme |
styles | Styles | defaultStyles | no | Custom styles |
📊 Comparison
🖼 Usage as static
import { EmojiKeyboard } from 'rn-emoji-keyboard';
// ...
<EmojiKeyboard onEmojiSelected={handlePick} />
Example about serving as static keyboard you can find here.
🎨 Theme
You can override color palette with custom colors using theme
prop.
const defaultTheme: Theme = {
backdrop: '#00000055',
knob: '#ffffff',
container: '#ffffff',
header: '#00000099',
category: {
icon: '#000000',
iconActive: '#005b96',
container: '#e3dbcd',
containerActive: '#ffffff',
},
search: {
text: '#000000cc',
placeholder: '#00000055',
icon: '#00000055',
background: '#00000011',
},
}
📏 Styles
You can also override styles to almost every element using styles
prop in the following format.
type Styles = {
container: ViewStyle
header: TextStyle
knob: ViewStyle
category: {
container: ViewStyle
icon: TextStyle
}
searchBar: {
container: ViewStyle
text: TextStyle
}
}
🇺🇸 Internationalization
Pre-defined
Due to the limited translation possibilities, we only provide a few pre-defined translations into the following languages:
-
en
- English 🇺🇸 -
pl
- Polish 🇵🇱 -
fr
- French 🇫🇷 -
it
- Italian 🇮🇹 -
ko
- Korean 🇰🇷 -
id
- Indonesian 🇲🇨 -
es
- Spanish 🇪🇸 -
de
- German 🇩🇪 -
pt
- Portuguese 🇧🇷 -
ua
- Ukrainian 🇺🇦 -
ru
- Russian 🇷🇺 -
vi
- Vietnamese 🇻🇳
First import lang and use it as translation
prop.
import { pl } from 'rn-emoji-keyboard';
// ...
translation={pl}
🏁 Own
There is possibility to pass own translation to library with the prop called translation
like this
translation={{
smileys_emotion: 'Smileys & Emotion',
people_body: 'People & Body',
animals_nature: 'Animals & Nature',
food_drink: 'Food & Drink',
travel_places: 'Travel & Places',
activities: 'Activities',
objects: 'Objects',
symbols: 'Symbols',
flags: 'Flags',
}}
If you have written a translation into your language, we strongly encourage you to create a Pull Request and add your language to the package, following the example of other langs.
🎉 Examples
You can clone the repo and run yarn example ios
or yarn example android
to preview app with this examples.
Basic
Dark
Translated
Disabled Categories
Static Modal (without knob)
Static
Recently used
Categories Top
Categories Bottom
Search Bar
⚖️ License
MIT
📝 Contribute
If you want to contribute read the CONTRIBUTING.md guide.