Emoji
A virtualized emoji picker menu with instant search, scroll-synced category icons, an unrolling skin-tone selector, recent history, and a live preview footer.
import { EmojiInput } from '@uthereal/ui/emoji-input'Emoji input playground
Overview
EmojiInput renders the emoji picker menu itself: a search field, a scroll-synced monochrome category toolbar, an unrolling skin-tone selector, a virtualized keyboard-navigable grid, and an optional preview footer. It never renders a message composer or outer text box. Use surface="panel" (the default) for a standalone bordered surface, or surface="bare" to embed the grid edge to edge inside your own popover, sheet, or card.
The component bundles a compact Unicode Emoji 15.0 dataset parsed once on first use and shared across every picker on the page. Skin tones apply at render time rather than duplicating the dataset, and optional localStorage persistence reads only after hydration so server and initial client markup always match.
| Capability | Behavior |
|---|---|
| Dataset | Bundled Unicode Emoji 15.0 set across 8 categories plus a Recent/Popular section; parsed once and shared |
| Instant search | Multi-word name and keyword matching ranked by exact, prefix, word-start, and keyword matches; zero animation delay |
| Category toolbar | 9 monochrome 16px category icons with an accent bar that tracks scroll position and waits cleanly during tab jumps |
| Skin tones | 6 tones (0 default yellow to 5 dark) in a clip-path radiogroup; controlled (skinTone) or uncontrolled (defaultSkinTone) |
| Recent history | Up to recentLimit (default 27, max 54, 0 hides section); seeds from defaultRecent until a pick occurs |
| Virtualized grid | Renders only visible rows plus overscan and the active row; responsive column count (>= 6 at 36px minimum) or fixed columns |
Use EmojiInput for reaction menus, status badges, page icons, and emoji insertion menus paired with Text or Mention. Pass surface="bare" when embedding the picker inside a custom popover or toolbar panel. Do not use it as a UI icon picker, because emoji glyphs vary across operating systems.
Usage
'use client'
import { useState } from 'react'
import {
EmojiInput,
type EmojiSelection,
type SkinTone,
} from '@uthereal/ui/emoji-input'
export function ReactionPicker({
onInsert,
}: {
onInsert: (emoji: string, keepOpen: boolean) => void
}) {
const [tone, setTone] = useState<SkinTone>(0)
function handleSelect(
selection: EmojiSelection,
event: React.MouseEvent | React.KeyboardEvent,
) {
onInsert(selection.emoji, event.shiftKey)
}
return (
<EmojiInput
label="Insert emoji"
surface="bare"
skinTone={tone}
onSkinToneChange={setTone}
onSelect={handleSelect}
storageKey="app-emoji-picker"
/>
)
}Pass surface="bare" when your host supplies the popover or card container, and inspect event.shiftKey in onSelect to keep an outer popover open for consecutive picks. Omit skinTone to manage the tone locally, and pass storageKey={null} (the default) to keep recent picks and tone in memory for the current session only.
Examples
Embedded and browse-only modes
Set surface="bare" with showPreview={false} and columns={8} to drop a compact chromeless picker into an existing popover or sheet. Turn off searchable and set recentLimit={0} for a browse-only category menu with no search header or history section.
Curated reaction sets and skin tones
Pass defaultRecent to seed the Popular section with a domain-specific quick set before the user picks anything, and set defaultSkinTone (0 to 5) for an initial tone preference. Set showSkinTone={false} when picks do not need tone controls.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Emoji picker" | Accessible name of the picker, for the group and its search field. Name it for what the picks are for, in sentence case. |
searchPlaceholder | stringDefault: "Search emoji" | Placeholder of the search field, e.g. "Search emoji". Never a substitute for the label. |
defaultSkinTone | number | number | number | number | number | numberDefault: 0 | Initial skin tone, 0 the default yellow and 1 to 5 light to dark. Later argument edits do not reset a mounted instance; pass skinTone and onSkinToneChange to control it. |
recentLimit | integerDefault: 27 | Most recently picked emoji kept and shown in the Recent section, 0 to 54. 0 turns the section off; the default 27 fills about one phone row. |
defaultRecent | string[]Default: ["๐","โค๏ธ","๐","๐","๐","๐ฅ","๐","๐","โ
","๐","๐ฏ","๐","๐ค","๐","๐","๐
","๐ฅณ","๐"] | Emoji shown under Popular before anything is picked, at most 54. |
columns | integerโ | Emoji per row, 6 to 12. Omit it to fit as many 36px cells as the width allows, at least 6. |
autoFocus | booleanDefault: false | Focus the search field when the picker mounts. |
storageKey | string | nullDefault: null | Key under localStorage where picked emoji and the tone persist, or null (the default) to keep them in memory for the session only. |
searchable | booleanDefault: true | Show the search field. Turn it off for a browse-only menu. |
showSkinTone | booleanDefault: true | Show the skin tone menu. Turn it off when picks cannot take a tone. |
showPreview | booleanDefault: true | Show the preview footer with the active emoji, its name and keywords. |
surface | panel | bareDefault: "panel" | panel (the default) draws its own bordered raised surface; bare renders chromeless for embedding in a popover, sheet, or card. |
labels | EmojiInputLabelsโ | Accessible names, headings and announcements of the picker: the search field, clear button, categories, tone menu and its value, the grid, results and counts, the recent and popular sections, the empty state, the preview hint. Templates fill {tone}, {count}, {query} and {name}. Translate them with the rest of your interface. |
action | stringโ | Host action fired with the picked emoji, for AI-native hosts; onSelect reports every pick either way. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | EmojiInputThemeโ | Color mode, accent, and semantic tokens: the picker width and height (defaults 352ร408), besides the shared surface, border, radius and text tokens. See Theming for all keys and defaults. |
motion | none | subtle | expressiveDefault: "subtle" | The category indicator sliding under the category in view, the preview emoji settling in from a slight scale, and the tone menu unrolling. none makes them immediate; system reduced motion keeps a short fade. |
motionOptions | EmojiInputMotionOptionsโ | Springs or tweens for the category indicator (indicator) and the preview settle (preview). Durations are milliseconds. |
dir | ltr | rtlโ | Reading direction. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
onSelect(selection, event) | Fires on click, Enter, or Space. selection holds { emoji, base, name, skinTone }; check event.shiftKey. |
skinTone, onSkinToneChange | Controlled skin tone (0 | 1 | 2 | 3 | 4 | 5). Callback fires in both controlled and uncontrolled modes. |
onAction(action, emoji) | Fires the configured action name with the chosen tone-applied emoji for AI-native host dispatch. |
ref | Ref to the root picker <div>, which carries the resolved --ui-* CSS custom properties. |
preset | Application defaults (such as surface, storageKey, columns, and translated labels), overridden by props. |
tokens | CSS custom properties (--ui-*) applied last on the picker root, including --ui-emoji-input-width and height. |
className, style | Applied to the root picker element. |
| Native input attributes | Forwarded to the internal search <input role="searchbox"> (name, aria-*, data-*); typing is managed. |
Pure dataset and tone helpers (getEmojiDataset, findEmoji, applyTone, searchEmoji, isKnownEmoji, popularEmoji, toneModifiers, toneNames, emojiCategoryData, emojiVersion, initialEmojiTone, reconcileEmojiTone, reconcileEmojiRecent, and skinToneSchema) are also exported from @uthereal/ui/emoji-input.
Keyboard & accessibility
| Key | Interaction |
|---|---|
| Type (search or grid) | Filters all emoji by name and keyword; highlights the top match for Enter. Typing in the grid focuses search |
Enter (search) | Picks the active search match without leaving the search field. |
ArrowDown (search) | Moves focus into the emoji grid and activates the first cell if none is active. |
| Arrow keys (grid) | Moves across cells, preserving column across categories. ArrowUp from the first row returns focus to search. |
Home, End (grid) | Moves to the first or last emoji in the current row. Hold Ctrl or Cmd to jump to the first or last overall |
PageUp, PageDown (grid) | Moves vertically by one viewport of rows. |
Enter, Space (grid) | Picks the active emoji cell. |
ArrowLeft, ArrowRight (tabs) | Moves focus across category buttons (Home and End jump to ends); Enter or Space scrolls to category. |
| Arrow keys (tone menu) | Moves between the 6 skin-tone radios (Home/End jump to ends); Enter or Space selects and closes menu. |
Escape | Capture-phase precedence: closes the tone menu first, clears search second, then reaches any outer popover. |
The picker root uses role="group" named by label. The grid exposes role="grid" with aria-rowcount, aria-colcount, role="row" with aria-rowindex, section role="columnheader" spans, and role="gridcell" buttons named after each emoji. aria-activedescendant tracks the active cell from the search field while searching and from the grid while focused; the virtualizer always keeps the active row mounted so the active cell ID always resolves.
The category bar renders as role="toolbar" with roving tabIndex and aria-current on the section in view. The tone trigger uses aria-haspopup="true" and aria-expanded to open a role="radiogroup" of six named tones. Two pre-mounted role="status" (aria-live="polite") regions announce search result counts (labels.resultsCount, labels.noResults) and chosen emoji (labels.picked). The preview footer is aria-hidden="true" to avoid duplicate announcements.
In dir="rtl" (explicit or inherited), the skin-tone menu unrolls from the inline-end tone button toward inline-start, the category indicator glides in the reading direction, and horizontal arrow keys in the grid, toolbar, and tone menu follow reading order. forced-colors: active preserves panel borders, search focus edges, tone rings, focus outlines, active cell Highlight/HighlightText contrast, and the category indicator bar.
Motion and theming
- Category indicator: glides to the active category on the morph spring (
0.42s, bounce0.16) while scrolling; clicking a tab moves the indicator directly and holds it while the list scrolls smoothly to that section. - Skin-tone menu: unrolls out of the tone trigger via a CSS
clip-path: inset(...)transition (480mson Arc's standard curve) so rapid open and close toggles reverse cleanly mid-flight. - Cells and preview: pressing an emoji dips it to
0.84scale over120msand releases on Arc's CSS spring (580ms); active preview changes settle from0.82scale onmotionOptions.preview(snappyspring by default), while search results appear immediately with zero delay. - Reduced motion:
prefers-reduced-motion: reducedisables indicator travel, tone-menu clip transitions, cell press scale, preview scale, and smooth scrolling while keeping a fast indicator opacity fade (160ms).motion="none"makes every transition and scroll jump immediate (0ms).
theme accepts the core token group plus borderStrong, borderSubtle, surfaceSunken, shadowRaised, popupRadius, itemRadius, and two component tokens: width (--ui-emoji-input-width, default 352px) and height (--ui-emoji-input-height, default 408px). An optional UtherealProvider supplies application-wide defaults.
Composition
EmojiInput is a leaf component. Its last picked emoji is host state at /fields/instance-<id>/lastEmoji, and its active skin tone (0 to 5) is host state at /fields/instance-<id>/skinTone (initialized from defaultSkinTone). Stored values survive configuration edits while they remain valid emoji or tones. See Building with agents.
{
"type": "EmojiInput",
"props": {
"label": "Reaction picker",
"searchPlaceholder": "Search emoji",
"surface": "panel",
"action": "insert_emoji"
},
"children": []
}