Skip to content

Reaction picker

Pro

A reaction button that likes on tap, with a floating row of reactions on long press, hover or the keyboard; slide a finger along it to pick. Not an M3 component (@windmorph/react-pro).

import { ReactionPicker } 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 19 props below

ReactionPicker 19 props

  • optionstype readonly ReactionOption[]Required

    The reactions, in row order.

  • defaultOptiontype stringdefault the first option

    The id a plain tap picks.

  • valuetype string | null

    The picked reaction's id, or null for none (controlled).

  • defaultValuetype string | nulldefault null

    The reaction picked at first (uncontrolled).

  • opentype boolean

    Whether the row is open (controlled).

  • defaultOpentype booleandefault false

    Whether the row is open at first (uncontrolled).

  • disabledtype booleandefault false

    Disables the button (and closes the row).

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

    sm for comments and messages, md for posts.

  • varianttype "text" | "tonal"default "text"

    text, transparent; tonal, on a pill (a post's action row).

  • idleIcontype booleandefault true

    Whether the button shows the default option's icon before a reaction. false: a word ("Like") until there is one, as under a comment.

  • reftype Ref<HTMLButtonElement>

    The button element.

  • idtype string

    The button's id.

Events

  • onChangetype ((value: string | null) => void)

    Called with the new reaction's id, or null when the reaction is removed.

  • onOpenChangetype ((open: boolean) => void)

    Called when the row opens or closes.

Text

  • labelstype Partial<ReactionPickerLabels>

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

  • aria-describedbytype string

    More ids describing the button, e.g. a count of reactions shown beside it.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

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.

  • Text button

    Built

    Variant · Variants

  • Tonal button

    Built

    Variant · Variants

  • Size: small and medium

    Built

    Configuration · Variants, Message

  • No icon before reacting

    Built

    Configuration · Variants

  • A post's action bar

    Built

    Use case · Post

  • Reacting to a message, translated

    Built

    Use case · Message

M3 Expressive specs

Sizes
sm, md
Shape
rounded-corner-full

Theming & tokens

  • The button is transparent (tonal: a surface-container-high pill) with on-surface-variant content, and the picked option's color once picked. Disabled, it takes the system disabled-content opacity; in forced colours it keeps a 1px boundary (Highlight when picked).
  • The row is a surface-container-high pill at elevation 3. It scales and fades in from its anchor on the default spatial spring, and the option under the pointer grows 1.5× on the fast spatial spring. Under reduced motion the row only fades, and the option is shown at 1.5× at once.
  • Set the tokens below on :root, a theme wrapper, the button or classNames.row: the button and the portalled row both carry data-tokens="wm-reaction-picker", so the row's tokens reach it from outside. Emoji take type-scale sizes in px, so 200% text keeps them in their boxes.
  • classNames styles the button, icon, label, row and each option; reactionPickerStyles can be extended with new variants.
Reaction picker tokens
VariableDefaultPaints
--wm-reaction-picker-label-colorvar(--md-sys-color-on-surface-variant)The button’s icon and label with no reaction picked.
--wm-reaction-picker-tonal-container-colorvar(--md-sys-color-surface-container-high)The button’s pill in the `tonal` variant.
--wm-reaction-picker-height40pxVaries with size.The button’s height (32px at `sm`).
--wm-reaction-picker-padding-inline12pxVaries with size.Inside the button, at its sides (8px at `sm`).
--wm-reaction-picker-gap8pxVaries with size.Between the button’s icon and label (4px at `sm`).
--wm-reaction-picker-icon-size20pxVaries with size.The button’s icon box (18px at `sm`).
--wm-reaction-picker-icon-font-size16pxVaries with size.An emoji’s size in the button: `body-large`’s 16px (14px, `body-medium`’s, at `sm`), in px like its box, so 200% text never spills it.
--wm-reaction-picker-row-container-colorvar(--md-sys-color-surface-container-high)The floating row’s background.
--wm-reaction-picker-row-elevationvar(--md-sys-elevation-level-3)The floating row’s shadow.
--wm-reaction-picker-row-cornervar(--md-sys-shape-corner-full)The floating row’s corners.
--wm-reaction-picker-row-padding4pxBetween the row’s edge and its options.
--wm-reaction-picker-row-gap4pxBetween the options.
--wm-reaction-picker-option-size48pxEach option’s box, its touch target too: keep it 48px or more.
--wm-reaction-picker-option-icon-size32pxVaries with size.An option’s icon box at rest; it grows 1.5× when active (28px at `sm`).
--wm-reaction-picker-option-icon-font-size28pxVaries with size.An emoji’s size in an option: `headline-medium`’s 28px (24px, `headline-small`’s, at `sm`), in px like its box.
--wm-reaction-picker-option-current-container-colorvar(--md-sys-color-secondary-container)Behind the picked reaction’s option.