Emoji reaction
A tapback-style reaction button that opens a bar of Apple emoji and sends copies of your pick floating up out of it.
Click the button, then pick an emoji to throw it up the screen.
Loading component source...
Installation
pnpm dlx shadcn@latest add mox/mox-ui/emoji-reactionRun this command from your project directory to add the component and its dependencies.
- 1
Install the packages
pnpm add motion react-apple-emojis lucide-react @radix-ui/react-slot clsx tailwind-merge - 2
Add the utility file
lib/utils.tsimport { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs));} - 3
Copy and paste the code into your project
Loading source⦠- 4
Update the import paths to match your project
Point
@/lib/utilsto your utility file if your path aliases differ.
Usage
import { EmojiReaction } from "@/components/ui/emoji-reaction"
export function Demo() { return <EmojiReaction onReact={(name) => console.log(name)} />}
// or hang the bar off your own element<EmojiReaction asChild> <button className="rounded-2xl bg-card p-4">Nice work</button></EmojiReaction>Options
Pick a value to see the prop you would pass. Defaults are left out.
<EmojiReaction />Props
| Prop | Type | Default | Description |
|---|---|---|---|
emojis | string[] | Default: 5 default faces | Apple emoji names shown in the bar, hyphenated as on Emojipedia. Anything beyond the five defaults needs emojiData too. |
emojiData | EmojiData | Default: - | Emoji name to image map passed to EmojiProvider. Defaults to the five bundled faces; pass react-apple-emojis/src/data.json for the full set. |
onReact | (name: string) => void | Default: - | Called with the emoji name every time one is picked, including each repeat while it's held down. |
size | "sm" | "md" | "lg" | Default: "md" | Scale of the button, the bar, and the emoji that fly up. |
align | "left" | "center" | "right" | Default: "center" | Which edge of the bar lines up with the trigger. It still shifts inward when it would run off screen. |
asChild | boolean | Default: false | Uses your own child as the trigger instead of the built-in button, so the bar can hang off a message, card, or image. |
className | string | Default: - | Extra classes merged onto the root element. |
Click the button to pop the emoji bar open, or press and drag straight onto an emoji to pick it in one gesture. Hover an emoji to lift it. Pick one and 5 copies stream up off it, drifting apart, shrinking, and blurring out of focus as they climb. Hold the emoji down to keep them coming. The bar flips below the button when there's no room above, and arrow keys move along it. While it's open the button turns into a cross; click that, click outside, or press Escape to close. The button then shows your last pick.
Credits and license
Most components here are recreations of great work from around the web. I don't claim to be the original creator - this is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone; if I missed someone, let me know.
- Free to use and modify in both personal and commercial projects.
- Attribution to Mox UI is appreciated when using a component.
- Please don't resell the components as your own kit.