Emoji chips for acknowledging a message in one tap
Tab to a reaction · Space adds yours or takes it back
pnpm dlx shadcn@latest add @notchset-pro/reactionsAcknowledged in one tap: a chip per reaction, yours in the Signature.
Every shadcn style · one file
Import it and pass your content. The props that matter most are listed next.
"use client";
import * as React from "react";
import { cn } from "@/lib/utils";
import { Avatar } from "@/components/ui/notchset/avatar";
import type { FeedbackProps } from "@/lib/notchset/feedback";
import { useLessMotion } from "@/lib/notchset/motion";
import { EMOJI_PACK, Reactions, type Reaction } from "@/components/ui/notchset/reactions";
import { pressIn, useSelfPlay } from "./self-play";
/*
* Reactions in two looks, the emoji drawn from the pack. Burst, for a public post's reaction row: on first sight a
* hand presses Party once: the emoji springs out of its chip, eight copies rise and fade, one ring goes out, and the
* count rolls up; taking yours back rolls it down. Plain, the app's row under one message: on first sight a heart is
* added, it beats once and the count rolls 2 to 3. In both the face opens the set; a pick lands as a new chip.
*/
const SET = Object.keys(EMOJI_PACK);
const FACES: Record<string, string> = {
"Priya Raman": "https://notchset.dev/media/people/person-01.webp",
"Kevin Ito": "https://notchset.dev/media/people/person-08.webp",
"Ana Ruiz": "https://notchset.dev/media/people/person-05.webp",
"Ines Duarte": "https://notchset.dev/media/people/person-07.webp",
You: "https://notchset.dev/media/people/person-03.webp",
};
const WORDS = {
post: { tag: "New", date: "Changelog · November 12, 2026", title: "Dark mode, everywhere", body: "Every page now follows your system’s theme. Prefer one look? Pick it once in Settings." },
message: { name: "Priya Raman", time: "10:12", body: "The new onboarding is live. Thank you to everyone who tested it this week." },
};
const toggle = (emoji: string) => (l: Reaction[]) => {
const r = l.find((x) => x.emoji === emoji);
if (!r) return [...l, { emoji, count: 1, mine: true, who: ["You"] }];
return l.map((x) => (x.emoji !== emoji ? x : x.mine ? { ...x, count: x.count - 1, mine: false, who: x.who?.filter((w) => w !== "You") } : { ...x, count: x.count + 1, mine: true, who: [...(x.who ?? []), "You"] })).filter((x) => x.count > 0);
};
/* the press on arrival: one chip, once */
function useArrival(root: React.RefObject<HTMLDivElement | null>, emoji: string) {
const less = useLessMotion();
const play = useSelfPlay(root, { beats: [600], off: less });
React.useEffect(() => {
if (play.mine || play.step !== 0) return;
pressIn(root.current, `[data-row="${emoji}"]`);
}, [play.step, play.mine, root, emoji]);
return (e: React.SyntheticEvent) => e.nativeEvent.isTrusted && play.handOver();
}
export default function ReactionsDemo() {
const look = "burst" as "burst" | "plain";
const words = WORDS;
return look === "plain" ? <Plain words={words} /> : <Burst words={words} />;
}
type Look = { words: typeof WORDS; onFeedback?: FeedbackProps["onFeedback"] };
function Burst({ words, onFeedback: sound }: Look) {
const root = React.useRef<HTMLDivElement>(null);
const [list, setList] = React.useState<Reaction[]>([
{ emoji: "👍", count: 124 },
{ emoji: "❤️", count: 86 },
{ emoji: "🎉", count: 48 },
]);
const handOver = useArrival(root, "🎉");
return (
<div ref={root} onPointerDownCapture={handOver} onKeyDownCapture={handOver} className="w-[720px] max-w-full">
<article className="flex flex-col gap-5 rounded-[28px] bg-[var(--ns-raised)] p-6 shadow-[var(--ns-bezel),0_30px_60px_-40px_rgb(0_0_0/0.35)] max-sm:gap-4 max-sm:rounded-[22px] max-sm:p-4">
<header className="flex flex-col gap-2">
<p className="m-0 flex items-center gap-2 text-[13px] text-[var(--ns-ink-3)]">
<span className="rounded-full bg-[color-mix(in_oklab,var(--ns-signal)_12%,transparent)] px-2 py-0.5 text-[12px] font-[number:var(--ns-weight-medium)] text-[var(--ns-signal-ink)]">{words.post.tag}</span>
{words.post.date}
</p>
<h3 className="m-0 font-[family-name:var(--ns-font-display)] text-[32px] leading-[1.1] font-[number:var(--ns-weight-strong)] tracking-[-0.025em] text-[var(--ns-ink)] max-sm:text-[24px]">{words.post.title}</h3>
</header>
<Art />
<p className="m-0 text-[16px] leading-6 text-[var(--ns-ink-2)] max-sm:text-[15px]">{words.post.body}</p>
<Reactions look="burst" images={EMOJI_PACK} set={SET} reactions={list} onToggle={(e) => setList(toggle(e))} onFeedback={sound} className="gap-2.5 max-sm:gap-2" />
</article>
</div>
);
}
function Plain({ words, onFeedback: sound }: Look) {
const root = React.useRef<HTMLDivElement>(null);
const [list, setList] = React.useState<Reaction[]>([
{ emoji: "👍", count: 4, who: ["Kevin Ito", "Ana Ruiz", "Ines Duarte", "Lena Ortiz"] },
{ emoji: "❤️", count: 2, who: ["Kevin Ito", "Ana Ruiz"] },
]);
const handOver = useArrival(root, "❤️");
return (
/* the app's row at its true shape, shown enlarged on the stage */
<div ref={root} onPointerDownCapture={handOver} onKeyDownCapture={handOver} className="flex justify-center">
<div className="flex w-[420px] max-w-full gap-3">
<Avatar name={words.message.name} src={FACES[words.message.name]} size="sm" />
<div className="flex min-w-0 flex-1 flex-col gap-1">
<p className="m-0 flex items-baseline gap-2 text-[length:var(--ns-text-body)]">
<b className="font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{words.message.name}</b>
<span className="text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] tabular-nums">{words.message.time}</span>
</p>
<p className="m-0 text-[length:var(--ns-text-body)] leading-[var(--ns-lead-body)] text-[var(--ns-ink)]">{words.message.body}</p>
<Reactions images={EMOJI_PACK} set={SET} faces={FACES} reactions={list} onToggle={(e) => setList(toggle(e))} onFeedback={sound} className="mt-1.5" />
</div>
</div>
</div>
);
}
/* the post's artwork: one window, light on the left and dark on the right, split on a slant */
function Art() {
const pane = (dark: boolean) => (
<div className={cn("absolute inset-0 flex flex-col gap-3 p-6 max-sm:p-4", dark ? "bg-[#17171b]" : "bg-[#f4f4f1]")} style={dark ? { clipPath: "polygon(58% 0, 100% 0, 100% 100%, 42% 100%)" } : undefined}>
<div className="flex items-center gap-1.5">
{[0, 1, 2].map((i) => (
<span key={i} className={cn("size-2.5 rounded-full", dark ? "bg-white/18" : "bg-black/12")} />
))}
</div>
<div className="flex flex-1 gap-3">
<div className={cn("flex w-[26%] flex-col gap-2 rounded-[10px] p-3", dark ? "bg-white/6" : "bg-black/[.04]")}>
{[70, 52, 60, 44].map((w) => (
<span key={w} className={cn("h-2 rounded-full", dark ? "bg-white/16" : "bg-black/10")} style={{ width: `${w}%` }} />
))}
</div>
<div className="flex flex-1 flex-col gap-3">
<span className={cn("h-16 rounded-[12px] max-sm:h-8", dark ? "bg-[linear-gradient(135deg,#3a4fd9,#7b5cf0)]" : "bg-[linear-gradient(135deg,#c7d0ff,#e3d8ff)]")} />
<div className="grid flex-1 grid-cols-3 gap-3">
{[0, 1, 2].map((i) => (
<span key={i} className={cn("rounded-[10px]", dark ? "bg-white/7" : "bg-black/[.05]")} />
))}
</div>
</div>
</div>
</div>
);
return (
<div aria-hidden className="relative h-[250px] overflow-hidden rounded-[18px] shadow-[inset_0_0_0_1px_var(--ns-line)] max-sm:h-[150px]">
{pane(false)}
{pane(true)}
</div>
);
}"use client";
import * as React from "react";
import { cn } from "@/lib/utils";
import { Avatar } from "@/components/ui/notchset/avatar";
import type { FeedbackProps } from "@/lib/notchset/feedback";
import { useLessMotion } from "@/lib/notchset/motion";
import { EMOJI_PACK, Reactions, type Reaction } from "@/components/ui/notchset/reactions";
import { pressIn, useSelfPlay } from "./self-play";
/*
* Reactions in two looks, the emoji drawn from the pack. Burst, for a public post's reaction row: on first sight a
* hand presses Party once: the emoji springs out of its chip, eight copies rise and fade, one ring goes out, and the
* count rolls up; taking yours back rolls it down. Plain, the app's row under one message: on first sight a heart is
* added, it beats once and the count rolls 2 to 3. In both the face opens the set; a pick lands as a new chip.
*/
const SET = Object.keys(EMOJI_PACK);
const FACES: Record<string, string> = {
"Priya Raman": "https://notchset.dev/media/people/person-01.webp",
"Kevin Ito": "https://notchset.dev/media/people/person-08.webp",
"Ana Ruiz": "https://notchset.dev/media/people/person-05.webp",
"Ines Duarte": "https://notchset.dev/media/people/person-07.webp",
You: "https://notchset.dev/media/people/person-03.webp",
};
const WORDS = {
post: { tag: "New", date: "Changelog · November 12, 2026", title: "Dark mode, everywhere", body: "Every page now follows your system’s theme. Prefer one look? Pick it once in Settings." },
message: { name: "Priya Raman", time: "10:12", body: "The new onboarding is live. Thank you to everyone who tested it this week." },
};
const toggle = (emoji: string) => (l: Reaction[]) => {
const r = l.find((x) => x.emoji === emoji);
if (!r) return [...l, { emoji, count: 1, mine: true, who: ["You"] }];
return l.map((x) => (x.emoji !== emoji ? x : x.mine ? { ...x, count: x.count - 1, mine: false, who: x.who?.filter((w) => w !== "You") } : { ...x, count: x.count + 1, mine: true, who: [...(x.who ?? []), "You"] })).filter((x) => x.count > 0);
};
/* the press on arrival: one chip, once */
function useArrival(root: React.RefObject<HTMLDivElement | null>, emoji: string) {
const less = useLessMotion();
const play = useSelfPlay(root, { beats: [600], off: less });
React.useEffect(() => {
if (play.mine || play.step !== 0) return;
pressIn(root.current, `[data-row="${emoji}"]`);
}, [play.step, play.mine, root, emoji]);
return (e: React.SyntheticEvent) => e.nativeEvent.isTrusted && play.handOver();
}
export default function ReactionsDemo() {
const look = "burst" as "burst" | "plain";
const words = WORDS;
return look === "plain" ? <Plain words={words} /> : <Burst words={words} />;
}
type Look = { words: typeof WORDS; onFeedback?: FeedbackProps["onFeedback"] };
function Burst({ words, onFeedback: sound }: Look) {
const root = React.useRef<HTMLDivElement>(null);
const [list, setList] = React.useState<Reaction[]>([
{ emoji: "👍", count: 124 },
{ emoji: "❤️", count: 86 },
{ emoji: "🎉", count: 48 },
]);
const handOver = useArrival(root, "🎉");
return (
<div ref={root} onPointerDownCapture={handOver} onKeyDownCapture={handOver} className="w-[720px] max-w-full">
<article className="flex flex-col gap-5 rounded-[28px] bg-[var(--ns-raised)] p-6 shadow-[var(--ns-bezel),0_30px_60px_-40px_rgb(0_0_0/0.35)] max-sm:gap-4 max-sm:rounded-[22px] max-sm:p-4">
<header className="flex flex-col gap-2">
<p className="m-0 flex items-center gap-2 text-[13px] text-[var(--ns-ink-3)]">
<span className="rounded-full bg-[color-mix(in_oklab,var(--ns-signal)_12%,transparent)] px-2 py-0.5 text-[12px] font-[number:var(--ns-weight-medium)] text-[var(--ns-signal-ink)]">{words.post.tag}</span>
{words.post.date}
</p>
<h3 className="m-0 font-[family-name:var(--ns-font-display)] text-[32px] leading-[1.1] font-[number:var(--ns-weight-strong)] tracking-[-0.025em] text-[var(--ns-ink)] max-sm:text-[24px]">{words.post.title}</h3>
</header>
<Art />
<p className="m-0 text-[16px] leading-6 text-[var(--ns-ink-2)] max-sm:text-[15px]">{words.post.body}</p>
<Reactions look="burst" images={EMOJI_PACK} set={SET} reactions={list} onToggle={(e) => setList(toggle(e))} onFeedback={sound} className="gap-2.5 max-sm:gap-2" />
</article>
</div>
);
}
function Plain({ words, onFeedback: sound }: Look) {
const root = React.useRef<HTMLDivElement>(null);
const [list, setList] = React.useState<Reaction[]>([
{ emoji: "👍", count: 4, who: ["Kevin Ito", "Ana Ruiz", "Ines Duarte", "Lena Ortiz"] },
{ emoji: "❤️", count: 2, who: ["Kevin Ito", "Ana Ruiz"] },
]);
const handOver = useArrival(root, "❤️");
return (
/* the app's row at its true shape, shown enlarged on the stage */
<div ref={root} onPointerDownCapture={handOver} onKeyDownCapture={handOver} className="flex justify-center">
<div className="flex w-[420px] max-w-full gap-3">
<Avatar name={words.message.name} src={FACES[words.message.name]} size="sm" />
<div className="flex min-w-0 flex-1 flex-col gap-1">
<p className="m-0 flex items-baseline gap-2 text-[length:var(--ns-text-body)]">
<b className="font-[number:var(--ns-weight-medium)] text-[var(--ns-ink)]">{words.message.name}</b>
<span className="text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)] tabular-nums">{words.message.time}</span>
</p>
<p className="m-0 text-[length:var(--ns-text-body)] leading-[var(--ns-lead-body)] text-[var(--ns-ink)]">{words.message.body}</p>
<Reactions images={EMOJI_PACK} set={SET} faces={FACES} reactions={list} onToggle={(e) => setList(toggle(e))} onFeedback={sound} className="mt-1.5" />
</div>
</div>
</div>
);
}
/* the post's artwork: one window, light on the left and dark on the right, split on a slant */
function Art() {
const pane = (dark: boolean) => (
<div className={cn("absolute inset-0 flex flex-col gap-3 p-6 max-sm:p-4", dark ? "bg-[#17171b]" : "bg-[#f4f4f1]")} style={dark ? { clipPath: "polygon(58% 0, 100% 0, 100% 100%, 42% 100%)" } : undefined}>
<div className="flex items-center gap-1.5">
{[0, 1, 2].map((i) => (
<span key={i} className={cn("size-2.5 rounded-full", dark ? "bg-white/18" : "bg-black/12")} />
))}
</div>
<div className="flex flex-1 gap-3">
<div className={cn("flex w-[26%] flex-col gap-2 rounded-[10px] p-3", dark ? "bg-white/6" : "bg-black/[.04]")}>
{[70, 52, 60, 44].map((w) => (
<span key={w} className={cn("h-2 rounded-full", dark ? "bg-white/16" : "bg-black/10")} style={{ width: `${w}%` }} />
))}
</div>
<div className="flex flex-1 flex-col gap-3">
<span className={cn("h-16 rounded-[12px] max-sm:h-8", dark ? "bg-[linear-gradient(135deg,#3a4fd9,#7b5cf0)]" : "bg-[linear-gradient(135deg,#c7d0ff,#e3d8ff)]")} />
<div className="grid flex-1 grid-cols-3 gap-3">
{[0, 1, 2].map((i) => (
<span key={i} className={cn("rounded-[10px]", dark ? "bg-white/7" : "bg-black/[.05]")} />
))}
</div>
</div>
</div>
</div>
);
return (
<div aria-hidden className="relative h-[250px] overflow-hidden rounded-[18px] shadow-[inset_0_0_0_1px_var(--ns-line)] max-sm:h-[150px]">
{pane(false)}
{pane(true)}
</div>
);
}"use client";
import * as React from "react";
/*
* A demo that plays itself until the first touch: the script lives in the demo, never in the piece, which only gets
* the props a person would give it. It moves 0.4 s after the piece is first seen, then takes each step on its beat;
* off screen or paused it waits. The first press, key or focus on the piece (bind `handOver` to it; a scroll over it never counts) makes it the
* visitor's for good and drops every queued step; with less motion (`off`) it never plays and rests in its first frame.
* A host can hand it over from outside the piece too (a settings panel beside it the visitor has used): under
* <HandedOver value>, it never plays, a remount included.
*
* const play = useSelfPlay(root, { beats: [2800, 2800], loop: true, off: less });
* <div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} onFocusCapture={play.handOver}>
* play.step // the step it is at, -1 before its first
* play.control // "pause" while it plays, "play" once paused (a new take), "replay" once it is over or yours
*
* Each step presses the piece's own controls (pressIn), so the script shows exactly what a hand can do.
*
* A host that shows the piece once (<PlayOnce value={{ settle }}>) changes three things: the script starts when the
* piece is first half in view and never again on coming back, it never loops, and with less motion (or `settle`) it
* takes every step at once, so the piece rests on the END of its moment. `hold` is a reason not to play at all that is
* not motion (a mode with nothing to show): it holds in every host. Under <PlayOnce value={{ active: false }}> (a look
* that is mounted but not shown) it waits until it is shown.
*/
type SelfPlayOptions = {
/** how long each step waits after the one before it, in ms; the first step waits 0.4 s after the piece is seen */
beats: readonly number[];
/** starts over after the last step; without it the script plays once and rests */
loop?: boolean | undefined;
/** no self-play at all (less motion): the piece is the visitor's from the start */
off: boolean;
/** no self-play for a reason other than motion (a mode with nothing to show), in every host */
hold?: boolean | undefined;
};
/** How a host shows the piece: once on arrival (see useSelfPlay). */
type PlayOnceHost = {
/** rest on the end at once, without playing (less motion, or a reset) */
settle?: boolean | undefined;
/** false while the piece is mounted but not shown: it waits */
active?: boolean | undefined;
};
const START = 400;
/**
* Whether a demo plays itself at all. Off: every piece rests in its first frame and is
* the visitor's from the start; nothing presses its controls for them.
*/
const SELF_PLAY: boolean = false;
/** True where the visitor has already taken the piece from outside it: nothing under it plays itself. */
const HandedOver = React.createContext(false);
/** A host that shows the piece once: play once on arrival, rest on the end (null: play as the demo asks). */
const PlayOnce = React.createContext<PlayOnceHost | null>(null);
function useSelfPlay(root: React.RefObject<Element | null>, { beats, loop: looped = false, off: still, hold = false }: SelfPlayOptions) {
const once = React.useContext(PlayOnce);
const active = once?.active !== false;
/* shown once: less motion (or a settled host) takes every step at once and rests on the end */
const quick = once != null && (still || Boolean(once.settle));
const loop = once == null && looped;
/* the first touch hands it over for good */
const [mine, setMine] = React.useState(false);
const handOver = React.useCallback(() => setMine(true), []);
const handedOver = React.useContext(HandedOver);
const off = !SELF_PLAY || hold || (quick ? false : still) || mine || (handedOver && !quick);
const [seen, setSeen] = React.useState(false);
const [paused, setPaused] = React.useState(false);
const [taken, setTaken] = React.useState(0);
const n = Math.max(1, beats.length);
const done = !loop && taken >= n;
React.useEffect(() => {
const el = root.current;
if (!active) return;
/* without an observer (an old browser, a test) it counts as seen */
if (!el || typeof IntersectionObserver === "undefined" || quick) {
const t = window.setTimeout(() => setSeen(true));
return () => window.clearTimeout(t);
}
/* shown once: first half in view starts it, and leaving never stops or restarts it */
const io = once
? new IntersectionObserver((es) => {
if (es.some((e) => e.isIntersecting && e.intersectionRatio >= 0.5)) {
setSeen(true);
io.disconnect();
}
}, { threshold: 0.5 })
: new IntersectionObserver((es) => setSeen(es.some((e) => e.isIntersecting)));
io.observe(el);
return () => io.disconnect();
}, [root, active, once, quick]);
const playing = !off && seen && active && !paused && !done;
const delay = quick ? 0 : taken === 0 ? START : (beats[taken % n] ?? START);
React.useEffect(() => {
if (!playing) return;
const t = window.setTimeout(() => setTaken((k) => k + 1), delay);
return () => window.clearTimeout(t);
}, [playing, taken, delay]);
/* one control in one place: Pause while it plays, Play (a new take) once paused, Replay once it is over or yours */
/* self-play off: never "over", so a demo rests in its FIRST frame, not its end frame */
const control: "pause" | "play" | "replay" = paused || !SELF_PLAY ? "play" : off || done ? "replay" : "pause";
return { step: taken === 0 ? -1 : (taken - 1) % n, taken, playing, control, mine, handOver, pause: () => setPaused(true) };
}
/**
* Presses a real control inside `root`, as the visitor would: the first match of `selector`, or the one whose text is
* `text`. A click only, so it never counts as the visitor's touch.
*/
function pressIn(root: Element | null, selector: string, text?: string) {
const all = [...(root?.querySelectorAll<HTMLElement>(selector) ?? [])];
(text == null ? all[0] : all.find((el) => el.textContent?.trim() === text))?.click();
}
export { HandedOver, PlayOnce, pressIn, useSelfPlay, type PlayOnceHost, type SelfPlayOptions };components/ui/notchset/reactions.tsx
This component is included with Pro.
Try the live preview above. Get Pro to install the source.
LevelOrganism: made of molecules or blocks.
Made ofAvatar,Emoji picker,Popover,Tooltip
Needs your registry key. Every components.json style gets the same files.
Works with React 18.3 or 19 on Tailwind CSS v4, in any shadcn project. What's tested
The CLI adds the styles to the CSS file named in components.json (tailwind.css). Check that it points at your global stylesheet, that the project uses Tailwind CSS v4, and that the file is imported in your root layout. Installed by hand: paste styles.css into that file.
The sound you hear is this page's: the piece you install plays none, and calls onFeedback on each move so you can add your own.
reactions–
Reaction[]Required.
onToggle–
(emoji: string) => voida reaction tapped: add yours, or take it back
set["👍", "❤️", "🎉", "👀", "✅", "🙏"]
string[]the quick set the face offers first
faces–
Record<string, string>photos for the names in `who`, shown as faces in a chip's tip
labels–
Partial<typeof REACTIONS_LABELS>its words, English by default
images–
Record<string, EmojiImage>emoji drawn as pictures (`EMOJI_PACK`); one not in the map stays text
look"plain"
"plain" | "burst""plain" (the default): the app's chips; "burst": a public post's row, larger, a press bursts the emoji
onFeedback–
(e: FeedbackEvent) => voidcalled once per move, for your sound or haptics
Three usesa comment's reactions · a chat message · an assistant's answer
Give your coding assistant the Markdown guide instead of screenshots.
https://notchset.dev/api/mcp (setup)One payment, lifetime.
v2.0.0 · 2026-10-13
Released with the Notchset system.