UnflowUI
Components

EmojiPicker

An emoji picker with search, a frequently used row, categories and a skin tone switch, as a popover or inline panel.

Overview

EmojiPicker lets people search for and pick an emoji. It shows a "Frequently used" row while the search is empty, emoji grouped by category, and a skin tone switch. onSelect returns the unicode emoji, never a shortcode. It is built on frimousse.

There are two exports:

  • EmojiPicker: the picker in a popover anchored to an element, usually the button that opened it. It closes on Esc, on click away and, by default, after a selection.
  • EmojiPickerPanel: the same picker without the popover, for use inside your own layout.

The app owns the history: pass the emoji to show in frequentlyUsed and update it from onSelect.

Import

import { EmojiPicker, EmojiPickerPanel } from '@unflowio/ui/components/EmojiPicker';

Props

EmojiPickerPanel

PropTypeDefaultDescription
onSelect(emoji: string) => void—Required. Called with the selected emoji as a unicode string
frequentlyUsedstring[]—Emoji shown above the list while the search is empty. The app stores this history
skinToneEmojiSkinTone—Controlled skin tone
defaultSkinToneEmojiSkinTone'none'Initial skin tone when uncontrolled
onSkinToneChange(skinTone: EmojiSkinTone) => void—Fired when the skin tone changes
columnsnumber8Emoji per row
localestringthe active i18n languageEmojibase locale for labels, categories and search
emojibaseUrlstringjsDelivr CDNWhere Emojibase data is fetched from, for self-hosting
resolveEmojiDataEmojiDataResolver—Supplies emoji data directly instead of fetching it
autoFocusbooleantrueFocuses the search field on mount

EmojiSkinTone is 'none' | 'light' | 'medium-light' | 'medium' | 'medium-dark' | 'dark'.

EmojiPicker

Takes every EmojiPickerPanel prop, plus:

PropTypeDefaultDescription
openboolean—Required. Whether the popover is open
anchorElElement | null—Required. Element the picker is positioned against, usually the button that opened it
onOpenChange(open: boolean) => void—Called with false on Escape, on click away and after a selection (see closeOnSelect)
placementPlacement'bottom-start'Floating UI placement relative to anchorEl
closeOnSelectbooleantrueCloses the picker after a selection

Emoji data

Emoji names, categories, keywords and skin tone variants come from Emojibase. By default the picker fetches that data from the jsDelivr CDN the first time it opens, in the language set by locale (or the active i18n language).

  • To serve the data yourself, for example under a strict Content Security Policy or on an offline network, host the Emojibase files and set emojibaseUrl to their location.
  • To skip fetching altogether, pass resolveEmojiData, a function that returns the data for a locale (or a promise of it).

The previews on this page pass resolveEmojiData with a small built-in set of emoji, so the docs make no network requests. In your app, leave it out and the picker loads the full set.

Basic usage

Picked: nothing yet

const [anchor, setAnchor] = useState<HTMLButtonElement | null>(null);
const [open, setOpen] = useState(false);

<Button
  ref={setAnchor}
  label="Add reaction"
  variant="secondary"
  onClick={() => setOpen((value) => !value)}
/>
<EmojiPicker
  open={open}
  anchorEl={anchor}
  onOpenChange={setOpen}
  onSelect={(emoji) => addReaction(emoji)}
  frequentlyUsed={recentEmoji}
/>

Set closeOnSelect={false} to let people pick several emoji in a row.

Inline panel

Frequently used

Loading emoji…
<div className="w-fit rounded-xl border border-border-muted bg-surface-raised">
  <EmojiPickerPanel
    frequentlyUsed={recentEmoji}
    onSelect={(emoji) => insert(emoji)}
    autoFocus={false}
  />
</div>

Skin tone

The skin tone switch sets the tone for every emoji that has variants. Uncontrolled, it starts at defaultSkinTone. To remember a person's choice, control it with skinTone and onSkinToneChange and store the value yourself.

<EmojiPicker
  open={open}
  anchorEl={anchor}
  onOpenChange={setOpen}
  onSelect={addReaction}
  skinTone={preferences.skinTone}
  onSkinToneChange={(skinTone) => savePreferences({ skinTone })}
/>

Accessibility

  • The search field is focused when the picker opens (turn this off with autoFocus={false}). Type to filter, use the arrow keys to move through results, and press Enter to pick.
  • Emoji are exposed in a grid, each named by its Emojibase label in the active language (e.g. "thumbs up").
  • The skin tone switch announces the current tone.
  • EmojiPicker is a dialog named "Emoji picker" and closes on Esc.
  • Labels such as "Search emoji", "Frequently used" and "Loading emoji…" are translated.