Skip to content

Reaction summary

Pro

The reactions so far: the top kinds’ icons and how many, stacked under a post or as a chip in a comment; pressable to see who reacted. Not an M3 component (@windmorph/react-pro).

import { ReactionSummary } from '@windmorph/react-pro';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Props

By name or description, across the 13 props below

ReactionSummary 13 props

  • itemstype readonly ReactionSummaryItem[]Required

    The top kinds, most first.

  • totaltype numberRequired

    How many reactions in all. Nothing renders at 0.

  • varianttype "stacked" | "chip"default "stacked"

    stacked (under a post) or chip (at the end of a comment's actions).

  • maxtype numberdefault 3

    How many icons show, e.g. 1 in a narrow row.

  • sizetype "sm" | "md"default "md"

    sm for comments and messages, md for posts. It sets the icons' size, a stacked count's type (label-large, label-medium at sm) and a pressable stacked summary's height and padding (40px and 12px, 32px and 8px at sm): the reaction picker's at the same size, so the two sit level in one row.

  • reftype Ref<HTMLElement>

    The root element: a <button> when pressable, otherwise a <span>.

  • idtype string

    The root element's id.

Events

  • onPresstype (() => void)

    Opens the list of who reacted; without it, the summary is plain text.

Text

  • labelstype Partial<ReactionSummaryLabels>

    Every word the summary says, from the app's translations. Each key's default is on ReactionSummaryLabels. A LabelsProvider sets them for the whole app.

  • aria-describedbytype string

    More ids describing the summary.

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

Theming & tokens

Set the tokens below on a summary or any ancestor; match --wm-reaction-summary-icon-ring to the surface it sits on. A chip also carries the assist chip's tokens (data-tokens="md-comp-assist-chip wm-reaction-summary"), so an app's chip theme reaches it; chip-container defaults to transparent and chip-corner to the small corner, as M3's flat chip. Style the parts with classNames (root, icons, icon, count).

Reaction summary tokens
VariableDefaultPaints
--wm-reaction-summary-icon-size24pxVaries with size.Each reaction icon’s circle (`stacked`).
--wm-reaction-summary-icon-font-size16pxVaries with size.An emoji icon’s size inside it: `body-large`’s 16px (14px, `body-medium`’s, at `sm`), in px like the circle, so 200% text never covers it.
--wm-reaction-summary-icon-containervar(--md-sys-color-surface-container-highest)Behind each icon (`stacked`).
--wm-reaction-summary-icon-ringvar(--md-sys-color-surface-container)The ring that separates overlapping icons; match the surface below.
--wm-reaction-summary-icon-ring-width2pxIts width.
--wm-reaction-summary-icon-overlap4pxHow far each icon overlaps the one before.
--wm-reaction-summary-chip-containertransparentThe chip’s background (`chip`): none, as M3’s flat chips.
--wm-reaction-summary-chip-cornervar(--md-sys-shape-corner-small)The chip’s corners: 8px, as every M3 chip.
--wm-reaction-summary-count-colorvar(--md-sys-color-on-surface-variant)The count.
--wm-reaction-summary-gap4pxBetween the icons and the count.
--wm-reaction-summary-button-height40pxVaries with size.A pressable `stacked` summary’s height: the reaction picker’s, 32px at `sm` (its touch target is 48px).
--wm-reaction-summary-button-padding-inline12pxVaries with size.Inside a pressable `stacked` summary, at its sides: the reaction picker’s, 8px at `sm`.