Skip to content

Getting Started

pnpm add react-emoji-text @emoji-mart/data

See Data Sources for a full comparison of the two options.

Wrap your app with EmojiProvider and use EmojiText to render emoji-enriched text.

import emojiMartData from '@emoji-mart/data';
import { fromEmojiMart } from 'react-emoji-text/adapters/emoji-mart';
import { EmojiProvider, EmojiText } from 'react-emoji-text/react';
const data = fromEmojiMart(emojiMartData);
export function Message() {
return (
<EmojiProvider data={data}>
<EmojiText>hello :wave:</EmojiText>
</EmojiProvider>
);
}
hello 👋 world ❤️
import { EmojiProvider, EmojiText } from 'react-emoji-text/react';
import { tokenize } from 'react-emoji-text/core';
import { fromEmojiMart } from 'react-emoji-text/adapters/emoji-mart';
import { fromEmojibase } from 'react-emoji-text/adapters/emojibase';
import Emoji, { toArray } from 'react-emoji-text/compat';

The root entry (react-emoji-text) re-exports the core and React APIs. Use the subpath entries when you want the smallest import surface.

PropTypeDefaultDescription
dataEmojiDatarequiredEmoji dataset — use fromEmojiMart() or fromEmojibase() adapters
set"native" | "apple" | "google" | "twitter" | "facebook""native"Emoji image set
defaultSkin1 | 2 | 3 | 4 | 5 | 6Default skin tone applied to all emojis
asciibooleantrueMatch ASCII emoticons like :) and <3
customEmojisCustomEmojiCategory[]Custom emoji categories
extraAliasesRecord<string, string>Additional shortcode mappings
getImageUrl(emoji, context) => stringCustom image URL resolver
imageUrlTemplatestringURL template with {set}, {unified}, {skin} placeholders
spriteSpriteConfigSprite sheet configuration

All EmojiProvider props except data can be overridden per-instance on EmojiText.

PropTypeDefaultDescription
childrenstringSource text (mutually exclusive with text)
textstringSource text (use when children contains slots)
askeyof HTMLElementTagNameMap"span"Wrapper element tag
classNamestringClass on the wrapper element
emojiClassNamestringClass applied to individual emoji images
onlyEmojiClassNamestringClass applied to the wrapper when content contains only emojis
refRef<HTMLElement>Forwarded ref to the wrapper element

Any additional HTML attributes are forwarded to the wrapper element.

<EmojiText as="p" className="message" data-testid="msg" title="Greeting">
hello :wave:
</EmojiText>