Overview
ReactionButton composes Button into a compact emoji reaction with a count. Your application supplies the pressed state, accessible name, and change handler.
Usage
Appearance
The control is 24px tall, with rounded corners, a 16px emoji, and a small count. Pressed reactions use the theme’s accent surface and text. Unpressed reactions use a transparent surface and secondary text.count accepts a number or a caller-formatted string. Your application owns number formatting, abbreviation, and whether to display a reaction with a zero count.
State ownership
pressed is required and controlled by your application. Activation calls onPressedChange with the requested next value. The component keeps showing the supplied pressed and count until your application updates them.
Set loading while a mutation is pending to show Button’s loading indicator and prevent repeated activation. It preserves the supplied pressed value and marks the control busy. Use disabled when the reaction is unavailable. Selection, counts, permissions, persistence, and any optimistic updates stay in the application.
Native onClick runs before the change request. Calling event.preventDefault() in that handler cancels the request. Other native button attributes, handlers, styles, class names, and refs pass through to the button. The control always uses type="button".
Accessibility and tooltips
Providearia-label or aria-labelledby with a localized reaction name. Emoji and count are decorative and hidden from assistive technology, so include count or participant information in the supplied name or description when needed. Keep the reaction name stable as its state changes; aria-pressed communicates selection.
The native button supports Tab focus and activation with Enter or Space. Both disabled and loading prevent activation. The ref points to the native button.
Compose Tooltip for participant details on hover and keyboard focus, as shown above, or pass a native title. Tooltip content belongs to the caller and does not replace the accessible name. Long accessible labels do not enlarge the visible control.
Props
Displayed count. Pass a string for localized or abbreviated formatting. Hidden from assistive technology.
Shows a loading indicator, sets
aria-busy, and prevents activation without changing the supplied pressed state.Native click handler called before
onPressedChange. Calling preventDefault() cancels the change request.Requests the next pressed state after activation. The caller updates
pressed and count.