← Components

Communication

Reaction picker

Hover or press the add button and reactions fan out of it; picking one pops it and sends a copy floating up.

Examples and variants

With bubble reactions

Pick a reaction; its count goes up.

Shipped the new toast!
Example
function EmojiReactions() {
  const [counts, setCounts] = useState<Record<string, number>>({ "👍": 3 })
  const labels: Record<string, string> = { "👍": "Thumbs up", "❤️": "Heart", "🎉": "Party", "😂": "Laugh", "😮": "Wow" }
  return (
    <div className="flex flex-col items-start gap-2">
      <Bubble>Shipped the new toast!</Bubble>
      <div className="flex items-center gap-2">
        <BubbleReactions
          reactions={Object.entries(counts).map(([emoji, count]) => ({ emoji, label: labels[emoji] ?? emoji, count }))}
          onReact={(emoji) => setCounts((all) => ({ ...all, [emoji]: (all[emoji] ?? 0) + 1 }))}
        />
        <ReactionPicker onPick={(emoji) => setCounts((all) => ({ ...all, [emoji]: (all[emoji] ?? 0) + 1 }))} />
      </div>
    </div>
  )
}

Spec drawing

Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.

Install

With the CLI

The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.

Terminal
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/reaction-picker.json

By hand

No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.

  1. Install the packages it uses.

    Terminal
    npm install cn lucide-react
  2. Copy this file to the same paths in your project. Imports use the @/ alias for your project root.

    • components/ui/reaction-picker.tsxreaction-picker
      components/ui/reaction-picker.tsx
      "use client"
      
      import * as React from "react"
      import { SmilePlusIcon } from "lucide-react"
      import { cn } from "cn"
      import { tokenMs } from "@/lib/motion/token-ms"
      
      /*
        Reaction picker: hover or press the add button and reactions fan out of it
        one by one. Picking one pops it and sends a copy floating up, then closes.
      */
      const defaults = [
        { emoji: "👍", label: "Thumbs up" },
        { emoji: "❤️", label: "Heart" },
        { emoji: "🎉", label: "Party" },
        { emoji: "😂", label: "Laugh" },
        { emoji: "😮", label: "Wow" },
      ]
      
      function ReactionPicker({
        onPick,
        reactions = defaults,
        className,
      }: {
        onPick: (emoji: string) => void
        reactions?: { emoji: string; label: string }[]
        className?: string
      }) {
        const [open, setOpen] = React.useState(false)
        const [floater, setFloater] = React.useState<{ emoji: string; id: number; x: number } | null>(null)
        const close = React.useRef(0)
      
        return (
          <span
            data-slot="reaction-picker"
            data-open={open || undefined}
            className={cn("relative inline-flex", className)}
            onPointerEnter={() => {
              window.clearTimeout(close.current)
              setOpen(true)
            }}
            onPointerLeave={() => {
              close.current = window.setTimeout(() => setOpen(false), tokenMs("--duration-fast"))
            }}
            onKeyDown={(event) => {
              if (event.key === "Escape") setOpen(false)
            }}
          >
            <button
              type="button"
              aria-label="Add reaction"
              aria-expanded={open}
              onClick={() => setOpen((value) => !value)}
              className="liquid-press inline-flex size-(--size-control-sm) items-center justify-center rounded-(--shape-full) bg-(--surface-container) text-muted-foreground outline-none hover:text-foreground focus-visible:shadow-(--focus-ring) [&_svg]:size-(--size-icon-sm)"
            >
              <SmilePlusIcon aria-hidden />
            </button>
            {open ? (
              <span role="group" aria-label="Reactions" className="reaction-tray absolute bottom-full start-0 mb-2 flex gap-1 rounded-(--shape-full) bg-(--reaction-tray) p-1 shadow-(--reaction-elevation)">
                {reactions.map((reaction, i) => (
                  <button
                    key={reaction.emoji}
                    type="button"
                    aria-label={reaction.label}
                    style={{ "--i": i } as React.CSSProperties}
                    onClick={(event) => {
                      const tray = event.currentTarget.parentElement!.getBoundingClientRect()
                      const box = event.currentTarget.getBoundingClientRect()
                      setFloater({ emoji: reaction.emoji, id: Date.now(), x: box.left - tray.left })
                      onPick(reaction.emoji)
                      setOpen(false)
                    }}
                    className="reaction-option inline-flex size-(--size-control-sm) items-center justify-center rounded-(--shape-full) text-lg outline-none hover:bg-(--reaction-option-container-hover) active:bg-(--reaction-option-container-pressed) focus-visible:shadow-(--focus-ring)"
                  >
                    <span aria-hidden>{reaction.emoji}</span>
                  </button>
                ))}
              </span>
            ) : null}
            {floater ? (
              <span key={floater.id} aria-hidden className="reaction-float pointer-events-none absolute bottom-full text-lg" style={{ left: floater.x }} onAnimationEnd={() => setFloater(null)}>
                {floater.emoji}
              </span>
            ) : null}
          </span>
        )
      }
      
      export { ReactionPicker }
      

Imports

What the examples on this page import:

Imports
import { Bubble, BubbleReactions } from "@/components/ui/bubble"
import { PickerWheel } from "@/components/ui/picker-wheel"
import { ReactionPicker } from "@/components/ui/reaction-picker"
import { RollingNumber } from "@/components/ui/rolling-number"
import { Slider } from "@/components/ui/slider"
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { ThemeToggle } from "@/components/ui/theme-toggle"

Anatomy

  1. 1Add button · Opens the tray.
  2. 2Tray · --reaction-tray, --reaction-elevation.
  3. 3Float · The picked emoji rises and fades.

Props

PropTypeDefaultDescription
onPick(emoji: string) => void—Called with the picked emoji.
reactions{ emoji, label }[]—Defaults to 5 common reactions.

Tokens

Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.

TokenPoints toLightDark
--reaction-trayvar(--surface-container-raised)oklch(1 0 0)oklch(0.22 0 0)
--reaction-elevationvar(--elevation-2)0 1px 1px -0.5px oklch(0.22 0.01 260 / 6%), 0 3px 3px -1.5px oklch(0.22 0.01 260 / 6%), 0 6px 6px -3px oklch(0.22 0.01 260 / 6%), 0 12px 12px -6px oklch(0.22 0.01 260 / 6%), 0 24px 24px -12px oklch(0.22 0.01 260 / 6%)0 4px 12px oklch(0 0 0 / 40%), 0 12px 28px oklch(0 0 0 / 35%)
--reaction-option-container-hovervar(--color-bg-hover)oklch(0.965 0.005 95)oklch(0.22 0 0)
--reaction-option-container-pressedvar(--color-bg-pressed)oklch(0.94 0.007 95)oklch(0.27 0 0)

Motion

TriggerWhat happensTokens
Open / pickOptions fan out with a stagger; the pick floats up.--duration-fast, --duration-stagger, --duration-settle

Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.

Accessibility

  • Each reaction is a labelled button; Escape closes; the add button reports aria-expanded.

Usage

Do

  • Pair with Bubble reactions to show counts.

Don’t

  • Don't offer more than 6 quick reactions.

Code

components/ui/reaction-picker.tsx
"use client"

import * as React from "react"
import { SmilePlusIcon } from "lucide-react"
import { cn } from "cn"
import { tokenMs } from "@/lib/motion/token-ms"

/*
  Reaction picker: hover or press the add button and reactions fan out of it
  one by one. Picking one pops it and sends a copy floating up, then closes.
*/
const defaults = [
  { emoji: "👍", label: "Thumbs up" },
  { emoji: "❤️", label: "Heart" },
  { emoji: "🎉", label: "Party" },
  { emoji: "😂", label: "Laugh" },
  { emoji: "😮", label: "Wow" },
]

function ReactionPicker({
  onPick,
  reactions = defaults,
  className,
}: {
  onPick: (emoji: string) => void
  reactions?: { emoji: string; label: string }[]
  className?: string
}) {
  const [open, setOpen] = React.useState(false)
  const [floater, setFloater] = React.useState<{ emoji: string; id: number; x: number } | null>(null)
  const close = React.useRef(0)

  return (
    <span
      data-slot="reaction-picker"
      data-open={open || undefined}
      className={cn("relative inline-flex", className)}
      onPointerEnter={() => {
        window.clearTimeout(close.current)
        setOpen(true)
      }}
      onPointerLeave={() => {
        close.current = window.setTimeout(() => setOpen(false), tokenMs("--duration-fast"))
      }}
      onKeyDown={(event) => {
        if (event.key === "Escape") setOpen(false)
      }}
    >
      <button
        type="button"
        aria-label="Add reaction"
        aria-expanded={open}
        onClick={() => setOpen((value) => !value)}
        className="liquid-press inline-flex size-(--size-control-sm) items-center justify-center rounded-(--shape-full) bg-(--surface-container) text-muted-foreground outline-none hover:text-foreground focus-visible:shadow-(--focus-ring) [&_svg]:size-(--size-icon-sm)"
      >
        <SmilePlusIcon aria-hidden />
      </button>
      {open ? (
        <span role="group" aria-label="Reactions" className="reaction-tray absolute bottom-full start-0 mb-2 flex gap-1 rounded-(--shape-full) bg-(--reaction-tray) p-1 shadow-(--reaction-elevation)">
          {reactions.map((reaction, i) => (
            <button
              key={reaction.emoji}
              type="button"
              aria-label={reaction.label}
              style={{ "--i": i } as React.CSSProperties}
              onClick={(event) => {
                const tray = event.currentTarget.parentElement!.getBoundingClientRect()
                const box = event.currentTarget.getBoundingClientRect()
                setFloater({ emoji: reaction.emoji, id: Date.now(), x: box.left - tray.left })
                onPick(reaction.emoji)
                setOpen(false)
              }}
              className="reaction-option inline-flex size-(--size-control-sm) items-center justify-center rounded-(--shape-full) text-lg outline-none hover:bg-(--reaction-option-container-hover) active:bg-(--reaction-option-container-pressed) focus-visible:shadow-(--focus-ring)"
            >
              <span aria-hidden>{reaction.emoji}</span>
            </button>
          ))}
        </span>
      ) : null}
      {floater ? (
        <span key={floater.id} aria-hidden className="reaction-float pointer-events-none absolute bottom-full text-lg" style={{ left: floater.x }} onAnimationEnd={() => setFloater(null)}>
          {floater.emoji}
        </span>
      ) : null}
    </span>
  )
}

export { ReactionPicker }