Skip to content
WunderUI

Emoji Reaction Button

Free

A pill with an emoji and a count that people switch on and off, like a reaction under a message.

npx wunderui-cli add emoji-reaction-button

Playground

Installation

bash
npx wunderui-cli add emoji-reaction-button

Writes the source into your project with its dependencies and, on first use, the styles - see Installation.

Then import what you need:

tsx
import {
  EmojiReactionButton,
} from "@/components/wunderui/emoji-reaction-button"
import type {
  EmojiReactionButtonProps,
} from "@/components/wunderui/emoji-reaction-button"

Then use it:

tsx
import { useState } from "react"
import { EmojiReactionButton } from "@/components/ui/emoji-reaction-button"

export function Reaction() {
  const [active, setActive] = useState(false)

  return (
    <EmojiReactionButton
      emoji="🔥"
      count={11 + (active ? 1 : 0)}
      active={active}
      onToggle={() => setActive((value) => !value)}
    />
  )
}

Expected result: You see a pill with a fire emoji and a count of 11. Press it and it turns indigo with the count at 12; press again to go back.

When to use

Use Emoji Reaction Button for

  • Reactions under a message, a comment, a post or a changelog entry
  • Quick feedback with a visible tally, such as helpful or not helpful
  • A small set of choices where people see how many others chose the same

Use something else for

  • Toggle for an on or off option for the person alone, such as bold or mute
  • Rating for a score from one to five
  • Badge for a read-only label or count that cannot be pressed

Content

Any emoji works, and the count is a number you keep in state. Switch a button on to see the count go up by one.

Keyboard interactions

The button is a native button, so the browser provides focus and activation.

TaborShiftTab
Moves focus to the next or previous reaction. Each one is a tab stop.
EnterorSpace
Switches the reaction on or off by calling . The screen reader announces the new pressed state.

Behavior and motion

What the button does with state, names and motion.

Controlled
The button keeps no state. The active state and count come from you, and every press calls the toggle handler without arguments, so nothing changes until you update them.
Pressed state
The pressed state follows the active one, so assistive technology announces pressed or not pressed. A reaction is a toggle, not a link or a menu.
Name
The accessible name is the emoji followed by the count, for example fire 12. It cannot be overridden, so say what the reaction means in text near the row.
States
Off has a neutral border, secondary text and hover and pressed fills; on has an indigo tint, border and text. Focus shows the indigo border and a 2 px ring.
Size
The pill is 26 px high with 8 px of side padding and 12 px text. It does not grow with the count, it only gets one digit wider at a time.
Numbers
The count is a plain number, so 1284 reads 1284. For large counts keep the figure short, or show a tally of your own beside the buttons.
Motion
Border, fill and text colour fade on the fast duration when the state changes. Nothing moves or scales.
Reduced motion
There is no movement to remove, so reduced motion changes nothing. The colour change is a short fade and stays.

Anatomy

The figure shows the button switched on. Off, the pill has the same parts with a neutral border and no tint.

  • data-slot="emoji-reaction-button"

    A native button that shows an emoji and a count and reports whether it is pressed. It is controlled: you hold the active state and count and change them in the toggle handler.

  • The 26 px high capsule with a 1 px border and a small gap between emoji and count. Off, it has a neutral border and secondary text; on, an indigo tint with indigo border and text.

  • The emoji character, at the text size of the pill. It is part of the button's accessible name, so a screen reader reads the emoji and then the count.

  • The number of people who reacted, shown as a plain number after the emoji. It does not change by itself when pressed, so update it in the toggle handler.

Best practices

  • Do

    Keep the active state and the count together and change them in the toggle handler: turning on adds one, turning off takes one away.

  • Do

    Show only the reactions that exist, and open an Emoji Picker from a small icon button for the rest. A reaction that drops to zero should disappear.

  • Do

    Put the buttons in a wrapping row with a gap, so they wrap on a narrow screen instead of overflowing.

  • Don’t

    Don't use it as a general toggle. It is for a reaction with a count; for an on or off option in a toolbar use Toggle.

  • Don’t

    Don't show a count of zero. A reaction nobody has chosen is not shown, and the Emoji Picker adds it again.

  • Don’t

    Don't use an emoji as the only information. Where the meaning matters, say it in text near the buttons.

  • Do

    Where the product shows no emoji, pass an icon and a label; the label names the button ("Agree: 3").

API reference

One table. EmojiReactionButton is a plain component that takes no other button attributes, so this table lists every prop.

A native button that shows an emoji and a count and reports whether it is pressed. It is controlled: you hold the active state and count and change them in the toggle handler.

PropTypeDefaultDescription
emojistring—The emoji to show, as a character. It is the first part of the button's accessible name.
count requirednumber—The number of people who reacted. It is shown as a plain number and does not change on its own: update it together with .
activeboolean—Whether the reaction is switched on. It sets and the indigo tint. Off by default.
onToggle() => void—Called without arguments when the button is pressed. Flip and change the count here.
classNamestring—Extra classes for the button, for example a margin in a row.
iconReactNode—The reaction as an icon (14 px, e.g. a thumbs up), in place of .
labelstring—What the reaction means ("Agree", "Thanks"): the accessible name is "<label>: <count>". Needed with an , which has no text of its own; replaces it entirely.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("emoji-reaction-button")
Installnpx wunderui-cli add emoji-reaction-button

The full library index for assistants is at /llms.txt.