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.

Purpose

A reaction button that likes on a tap, with a floating row of reactions that opens on a long press, when the mouse rests on it, or from the keyboard: the common pattern on social and work apps for posts, comments and messages. The timings (a long press against a tap, hover intent), the row's keyboard and focus, and sliding a finger along the row are easy to get wrong, so they live in one component. It is not an M3 component, so it comes from @windmorph/react-pro.

The reactions are yours: each option is { id, label, icon, color }, where icon is any node (an emoji or an SVG) and color is the colour role the button takes once that reaction is picked: a ReactionColor, one of REACTION_COLORS (primary, secondary, tertiary, error, success, warning, on-surface, on-surface-variant), each tested at 4.5:1 on the button and the row in every theme, mode and contrast level. Container roles aren't accepted. For a single on/off action, use a toggle IconButton or Button instead.

Behaviour

  • Without a reaction, the button shows the default option (defaultOption, or the first) with its outlineIcon, and a tap picks it. With one, it shows that reaction's icon and label in its colour, and a tap removes it.
  • variant: text (transparent, the default) or tonal (on a pill, as in a post's action row). idleIcon={false} makes the button a word ("Like") until there's a reaction, as under a comment. Pair it with a Reaction summary to show the reactions so far.
  • The row opens on a 500ms long press, after the mouse rests on the button for 600ms (it closes 300ms after the mouse leaves both), or with ArrowUp or Alt+ArrowDown. It sits above the button, or below when there's no room, and closes when the page scrolls.
  • In the row, the arrow keys move between reactions and wrap at the ends, and Home and End reach the first and last. The active option shows its name above it on the core's plain tooltip surface, and the picked reaction is exposed with aria-pressed. Closing the row returns focus to the button without scrolling the page.
  • On touch, keep the finger down after the long press and slide it along the row: the reaction under it grows and shows its name, and lifting picks it. Lifting over nothing leaves the row open; a tap elsewhere closes it.
  • value / onChange (or defaultValue) hold the reaction id or null; open / onOpenChange control the row.

When not to use

For a single on/off action, such as Save or Follow, use a toggle Button or IconButton.

See also

  • Icon button: A compact icon-only action; requires an accessible name.
  • Button: Five variants and five sizes for text actions, with a toggle form and a press morph.
  • Toolbars: Docked and floating toolbars of related actions, with an optional FAB, scroll collapse and scroll exit.