Emoji Picker component for React Applications on the web
74
The standalone Emoji component allows you to render individual emojis anywhere in your React application with customizable styling and sizing, independent of the full picker interface.
Renders a single emoji with configurable style, size, and loading behavior.
/**
* Standalone emoji rendering component
* @param props - Configuration for the emoji display
* @returns JSX element displaying the emoji
*/
declare const Emoji: (props: {
/** Unicode identifier for the emoji (required) */
unified: string;
/** Visual style of the emoji */
emojiStyle?: EmojiStyle;
/** Size of the emoji in pixels */
size?: number;
/** Whether to load the emoji image lazily */
lazyLoad?: boolean;
/** Custom function to generate emoji image URL */
getEmojiUrl?: GetEmojiUrl;
/** Direct URL to the emoji image (overrides getEmojiUrl) */
emojiUrl?: string;
}) => JSX.Element;Usage Examples:
import { Emoji, EmojiStyle } from "emoji-picker-react";
// Basic emoji rendering
function BasicEmoji() {
return <Emoji unified="1f60a" size={32} />;
}
// Different emoji styles
function StyledEmojis() {
return (
<div>
<Emoji unified="1f44d" emojiStyle={EmojiStyle.APPLE} size={24} />
<Emoji unified="1f44d" emojiStyle={EmojiStyle.GOOGLE} size={24} />
<Emoji unified="1f44d" emojiStyle={EmojiStyle.TWITTER} size={24} />
<Emoji unified="1f44d" emojiStyle={EmojiStyle.FACEBOOK} size={24} />
</div>
);
}
// Custom emoji URL
function CustomEmojiUrl() {
return (
<Emoji
unified="1f389"
emojiUrl="https://cdn.example.com/emojis/party.png"
size={48}
/>
);
}
// Lazy loading for performance
function LazyEmoji() {
return (
<Emoji
unified="1f680"
size={64}
lazyLoad={true}
emojiStyle={EmojiStyle.APPLE}
/>
);
}
// Custom emoji URL generation
function CustomUrlGeneration() {
const customUrlGenerator = (unified: string, style: EmojiStyle) => {
return `https://my-cdn.com/emojis/${style}/${unified}.png`;
};
return (
<Emoji
unified="1f4a9"
getEmojiUrl={customUrlGenerator}
emojiStyle={EmojiStyle.APPLE}
size={32}
/>
);
}Complete interface for the Emoji component props.
interface EmojiProps {
/**
* Unicode identifier for the emoji (e.g., "1f60a" for 😊)
* Required to identify which emoji to render
*/
unified: string;
/**
* Visual style/set for the emoji
* @default EmojiStyle.APPLE
*/
emojiStyle?: EmojiStyle;
/**
* Size of the emoji in pixels
* @default 32
*/
size?: number;
/**
* Whether to load the emoji image lazily for performance
* @default false
*/
lazyLoad?: boolean;
/**
* Custom function to generate emoji image URLs
* Receives unified code and style, returns image URL
*/
getEmojiUrl?: GetEmojiUrl;
/**
* Direct URL to the emoji image
* If provided, overrides getEmojiUrl and default URL generation
*/
emojiUrl?: string;
}Type definition for custom emoji URL generation function.
/**
* Function type for generating custom emoji image URLs
* @param unified - Unicode identifier for the emoji
* @param style - Emoji style being requested
* @returns URL string pointing to the emoji image
*/
type GetEmojiUrl = (unified: string, style: EmojiStyle) => string;Emojis are identified using their Unicode code points in hex format without the "U+" prefix:
// Examples of unified codes:
"1f60a" // 😊 smiling face with smiling eyes
"1f44d" // 👍 thumbs up
"2764-fe0f" // ❤️ red heart
"1f1fa-1f1f8" // 🇺🇸 US flag (multi-part emoji)
"1f44d-1f3fb" // 👍🏻 thumbs up with light skin toneFor emojis that support skin tone variations, append the skin tone code to the base emoji:
import { Emoji, SkinTones } from "emoji-picker-react";
function SkinToneExamples() {
return (
<div>
{/* Base emoji without skin tone */}
<Emoji unified="1f44d" size={32} />
{/* With different skin tones */}
<Emoji unified="1f44d-1f3fb" size={32} /> {/* Light */}
<Emoji unified="1f44d-1f3fc" size={32} /> {/* Medium-light */}
<Emoji unified="1f44d-1f3fd" size={32} /> {/* Medium */}
<Emoji unified="1f44d-1f3fe" size={32} /> {/* Medium-dark */}
<Emoji unified="1f44d-1f3ff" size={32} /> {/* Dark */}
</div>
);
}The Emoji component is optimized for performance:
lazyLoad={true} for emojis not immediately visiblesize prop to avoid unnecessary scalinggetEmojiUrl for CDN integration and custom emoji setsThe component handles various error scenarios gracefully:
The Emoji component works seamlessly with data from the EmojiPicker:
import EmojiPicker, { Emoji, EmojiClickData } from "emoji-picker-react";
function EmojiApp() {
const [selectedEmoji, setSelectedEmoji] = useState<EmojiClickData | null>(null);
return (
<div>
<EmojiPicker
onEmojiClick={(emojiData) => setSelectedEmoji(emojiData)}
/>
{selectedEmoji && (
<div>
<p>You selected:</p>
<Emoji
unified={selectedEmoji.unified}
size={48}
/>
<p>{selectedEmoji.names[0]}</p>
</div>
)}
</div>
);
}Install with Tessl CLI
npx tessl i tessl/npm-emoji-picker-reactevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10