2021-07-19 17:26:41 +00:00
# 🚀 rn-emoji-keyboard
2021-07-19 17:29:24 +00:00
A lightweight, fully customizable emoji picker, written as React Native component (without native elements). Designated to be user and developer friendly! 💖
2021-07-03 17:51:30 +00:00
2021-07-10 14:07:16 +00:00
![Preview ](/example/assets/preview-small.gif )
2021-07-03 17:51:30 +00:00
2021-07-19 17:26:41 +00:00
## 🪄 Installation
```sh
yarn add rn-emoji-keyboard
```
or
```sh
npm install rn-emoji-keyboard
```
## ⚡️ Usage
2021-07-03 17:51:30 +00:00
```js
2021-07-19 17:26:41 +00:00
import EmojiPicker from 'rn-emoji-keyboard';
2021-07-08 13:10:57 +00:00
export default function App() {
const [isOpen, setIsOpen] = React.useState< boolean > (false);
2021-07-03 17:51:30 +00:00
2021-07-08 13:10:57 +00:00
const handlePick = (emojiObject: EmojiType) => {
console.log(emojiObject);
2021-07-16 12:20:44 +00:00
/* example emojiObject = {
2021-07-08 13:10:57 +00:00
"emoji": "❤️",
"name": "red heart",
"slug": "red_heart",
2021-07-22 09:42:45 +00:00
"unicode_version": "0.6",
2021-07-16 12:20:44 +00:00
}
2021-07-08 13:10:57 +00:00
*/
};
2021-07-03 17:51:30 +00:00
2021-07-08 13:10:57 +00:00
return (
< EmojiPicker
2021-07-26 19:31:48 +00:00
onEmojiSelected={handlePick}
2021-07-08 13:10:57 +00:00
open={isOpen}
onClose={() => setIsOpen(false)} />
)
}
2021-07-03 17:51:30 +00:00
```
2021-07-19 17:26:41 +00:00
## ⚙️ Accepted props (current implemented)
2021-07-08 13:10:57 +00:00
| 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 |
2021-07-30 10:53:00 +00:00
| enableRecentlyUsed | boolean | false | no | Enable recently used emojis in categories |
2021-07-30 11:23:55 +00:00
| categoryPosition | 'floating' \| 'top' \| 'bottom' | 'floating' | no | Specify category container position |
| enableSearchBar | boolean | false | no | Enable search bar |
2021-07-30 11:20:38 +00:00
| closeSearchColor | string | "#00000055" | no | Change button (cross) color for close/cancel search |
2021-08-11 08:03:37 +00:00
| searchBarStyles | ViewStyle | {} | no | Override search bar container styles |
| searchBarTextStyles | ViewStyle | {} | no | Override search bar text styles |
| searchBarPlaceholderColor | string | "#00000055" | no | Override search bar placeholder color |
2021-07-08 13:10:57 +00:00
| headerStyles | TextStyle | {} | no | Override category name styles |
| knobStyles | ViewStyle | {} | no | Override knob styles |
| containerStyles | ViewStyle | {} | no | Override container styles |
| hideHeader | boolean | false | no | Hide category names |
| expandable | boolean | true | no | Show knob and enable expand on swipe up |
2021-07-10 10:39:52 +00:00
| 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_ |
2021-07-08 13:10:57 +00:00
| backdropColor | string | "#00000055" | no | Change backdrop color and alpha |
2021-07-10 10:05:18 +00:00
| categoryColor | string | "#000000" | no | Change category item color |
| activeCategoryColor | string | "#005b96" | no | Change active category item color |
| categoryContainerColor | string | "#e3dbcd" | no | Change category container color |
2021-07-20 09:47:01 +00:00
| activeCategoryContainerColor | string | "#ffffff" | no | Change selected category container color |
2021-07-10 13:42:55 +00:00
| onCategoryChangeFailed | function | warn(info) | no | Callback on category change failed (info: {index, highestMeasuredFrameIndex, averageItemLength}) |
2021-07-12 09:17:39 +00:00
| translation | CategoryTranslation | en | no | Translation object *see translation section* |
2021-07-12 11:57:10 +00:00
| disabledCategory | CategoryTypes[] | [] | no | Hide categories by passing their slugs |
2021-07-26 13:30:04 +00:00
2021-07-27 09:37:30 +00:00
## 📊 Comparison
![comparison table ](/example/assets/table-comparison-small.png )
## 🖼 Usage as static
2021-07-26 13:30:04 +00:00
```js
import { EmojiKeyboard } from 'rn-emoji-keyboard';
// ...
< EmojiKeyboard onEmojiSelected = {handlePick} / >
```
Example about serving as static keyboard [you can find here ](/example/src/Dark/Dark.tsx ).
2021-07-19 17:26:41 +00:00
## 🇺🇸 Internationalization
2021-07-12 09:17:39 +00:00
### Pre-defined
Due to the limited translation possibilities, we only provide a few pre-defined translations into the following languages:
2021-07-19 17:26:41 +00:00
* `en` - English 🇺🇸
* `pl` - Polish 🇵🇱
2021-07-12 09:17:39 +00:00
First import lang and use it as `translation` prop.
```ts
2021-07-19 17:26:41 +00:00
import { pl } from 'rn-emoji-keyboard';
2021-07-12 09:17:39 +00:00
// ...
translation={pl}
```
2021-07-19 17:26:41 +00:00
### 🏁 Own
2021-07-12 09:17:39 +00:00
There is possibility to pass own translation to library with the prop called `translation` like this
```ts
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.*
2021-07-20 10:19:41 +00:00
## 🎉 Examples
You can clone the repo and run `yarn example ios` or `yarn example android` to preview app with this examples.
2021-07-20 10:21:41 +00:00
### [Basic](/example/src/Basic/Basic.tsx)
2021-07-20 10:19:41 +00:00
![Preview ](/example/assets/light-preview.jpg )
2021-07-20 10:23:59 +00:00
### [Dark](/example/src/Dark/Dark.tsx)
2021-07-20 10:19:41 +00:00
![Preview ](/example/assets/dark-preview.jpg )
2021-07-20 10:23:59 +00:00
### [Translated](/example/src/Translated/Translated.tsx)
2021-07-20 10:19:41 +00:00
![Preview ](/example/assets/translated-preview.jpg )
2021-07-28 12:53:35 +00:00
### [Disabled Categories](/example/src/DisabledCategories/DisabledCategories.tsx)
2021-07-20 10:19:41 +00:00
![Preview ](/example/assets/categories-preview.jpg )
2021-07-28 12:53:35 +00:00
### [Static Modal (without knob)](/example/src/StaticModal/StaticModal.tsx)
2021-07-26 13:30:04 +00:00
![Preview ](/example/assets/static-modal-preview.jpg )
### [Static](/example/src/Static/Static.tsx)
2021-07-20 10:19:41 +00:00
![Preview ](/example/assets/static-preview.jpg )
2021-07-30 10:53:00 +00:00
### [Recently used](/example/src/EnableRecently/EnableRecently.tsx)
![Preview ](/example/assets/enable-recently-used-preview.jpg )
2021-07-28 12:53:35 +00:00
### [Categories Top](/example/src/TopCategory/TopCategory.tsx)
![Preview ](/example/assets/categories-top-preview.jpg )
### [Categories Bottom](/example/src/BottomCategory/BottomCategory.tsx)
![Preview ](/example/assets/categories-bottom-preview.jpg )
2021-07-29 10:02:11 +00:00
### [Search Bar](/example/src/SearchBar/SearchBar.tsx)
![Preview ](/example/assets/search-bar-preview.gif )
2021-07-19 17:26:41 +00:00
## 📈 Future plans
* Skin tone palette selector.
2021-07-26 13:30:04 +00:00
* Write native module to display forbidden emojis on android.
2021-07-19 17:26:41 +00:00
## ⚖️ License
2021-07-12 11:57:10 +00:00
** [MIT ](/LICENSE )**