Emoji Picker

Find an emoji by name or browse by category, for reactions, statuses and messages.

Yours: 🎉

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/emoji-picker

Usage

import { EmojiPicker, emojiMatches } from "./ui/uicontext/components/kit/Emoji.ts"
const Message = UiSchema.TaggedEnum({ Reacted: { emoji: Schema.String, on: Schema.Boolean } })// the reader's own reactions show chosen; picking one again takes it backexport const ReactionPicker = (h: Html.H<typeof Message.Type>, mine: ReadonlyArray<string>) =>	EmojiPicker(h, { props: { mine }, onEmit: { Picked: ({ emoji, on }) => Message.Reacted({ emoji, on }) } })// the same names drive ":tada" in a composerexport const firstMatch = emojiMatches("tada")[0]?.emoji

API reference

EmojiPickerComponent

Props

EmojiPicker props
NameTypeDescription
minestring[]Emoji the reader already used here, shown chosen; picking one again takes it back

Events

EmojiPicker events
EventPayloadDescription
Picked{ emoji: string; on: boolean }The reader picked an emoji: add it (on), or take back one they'd used

EmojiPanelView function

Options

EmojiPanel options
NameTypeDescription
queryrequiredstringWhat's typed in the search field
categoryrequired"frequent" | "people" | "nature" | "food" | "activity" | "travel" | "objects" | "symbols"The category tab that's open while nothing is typed
minestring[]Emoji the reader already used here (their reactions), shown chosen
searchrequired(input: InputBuilder<Message>, first: string | undefined) => InputBuilder<Message>Binds the search field: its input, and Enter to pick the first match
tabrequired(button: ButtonBuilder<Message>, category: EmojiCategory) => ButtonBuilder<Message>Binds a category tab's press
choicerequired(button: ButtonBuilder<Message>, emoji: string, on: boolean) => ButtonBuilder<Message>Binds an emoji's press: the emoji, and whether it adds the reader's (false takes it back)

Accessibility

  • The search field takes focus as the picker opens; Down moves into the grid, the arrows move by row and column, and Enter in the field picks the first match.
  • Each emoji is a button named for it (tada), pressed when it's already yours. Categories are toggle buttons.

Source