Emoji utilities
The data and search behind EmojiPicker, for your own UIs.
import { getAllEmojis, searchEmojis, findEmoji, withSkinTone } from '@elik56a/react-native-pickers';
getAllEmojisโ
getAllEmojis(): Emoji[]
All 1,923 emojis in display order. Parsed on the first call, then cached.
interface Emoji {
emoji: string;
name: string;
keywords: string[];
category: EmojiCategory;
version: number; // Emoji version, e.g. 0.6, 11, 15.1
skins?: string[]; // 5 variants, light โ dark
}
searchEmojisโ
searchEmojis(query: string, list: Emoji[] = getAllEmojis()): Emoji[]
Every word of the query must match. Results are ranked by:
- name starts with the word (3 points)
- a word of the name starts with it (2)
- a keyword starts with it (1)
- the name contains it (0.5)
Returns [] for an empty query.
Loadingโฆ
<View style={{ gap: 12 }}> <TextInput value={q} onChangeText={setQ} placeholder=":shortcode" style={{ borderWidth: 1, borderColor: '#E8E4DC', borderRadius: 10, padding: 10, }} /> <Text style={{ fontSize: 28, lineHeight: 40 }}> {results.map((e) => e.emoji).join(' ')} </Text> </View>
findEmojiโ
findEmoji(char: string): Emoji | undefined
Looks up an emoji by character. Matches skin-tone variants too (findEmoji('๐๐ฝ') returns ๐'s data) and ignores the U+FE0F variation selector.
withSkinToneโ
withSkinTone(e: Emoji, tone: SkinTone): string
withSkinTone(findEmoji('๐')!, 3) // '๐๐ฝ'
Returns the variant for tone 1โ5, or the base emoji for tone 0 or emojis without skins.
Constantsโ
EMOJI_CATEGORIES: EmojiCategory[]
// ['smileys', 'people', 'animals', 'food', 'travel', 'activities', 'objects', 'symbols', 'flags']
DEFAULT_CATEGORY_LABELS: Record<EmojiCategory | 'recent' | 'search', string>
// { recent: 'Recently used', search: 'Search results', smileys: 'Smileys & Emotion', โฆ }
DEFAULT_CATEGORY_ICONS: Record<EmojiCategory | 'recent', string>
// { recent: '๐', smileys: '๐', people: '๐', animals: '๐ป', food: '๐', travel: 'โ๏ธ', activities: 'โฝ', objects: '๐ก', symbols: 'โค๏ธ', flags: '๐ณ๏ธ' }
Example: quick reactionsโ
const QUICK = ['๐', 'โค๏ธ', '๐', '๐ฎ', '๐ข', '๐'];
const [tone] = useState<SkinTone>(2);
<View style={{ flexDirection: 'row' }}>
{QUICK.map((ch) => {
const e = findEmoji(ch)!;
const toned = withSkinTone(e, tone);
return <Pressable key={ch} onPress={() => react(toned)}><Text style={{ fontSize: 28 }}>{toned}</Text></Pressable>;
})}
</View>