Reaction picker
ProA 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.
Keyboard
| Key | Action | Where |
|---|---|---|
| Enter or Space | Toggles the reaction: picks the default option when there is none, or removes the one picked.On the button | On the button |
| Arrow Up or Alt + Arrow Down | Opens the row with focus on the picked reaction, or on the first.On the button | On the button |
| Arrow Left or Arrow Right | Moves to the previous or next reaction, wrapping from the last to the first.In the row | In the row |
| Home or End | Moves to the first or last reaction.In the row | In the row |
| Enter or Space | Picks the focused reaction, closes the row and returns focus to the button.In the row | In the row |
| Escape | Closes the row and returns focus to the button.In the row | In the row |
| Tab or Shift + Tab | Closes the row and leaves it as if it sat right after the button: Shift + Tab lands on the button, Tab on whatever follows it.In the row | In the row |
- Left and right are reversed in right-to-left layouts.
- The pointer ways to open the row (a long press, or resting the mouse on the button) all have this keyboard equivalent.
Screen reader
- Role
- The button is a toggle
button. The row is atoolbarofbuttons. - Accessible name
- The button is named by the reaction it shows: the picked one, or the default option. Each option is named by its
label; the row bylabels.reactions("Reactions"). - States announced
- The button is pressed or not pressed (
aria-pressed), expanded or collapsed (aria-expanded, witharia-controlspointing at the row while it shows), and describes how to open the row withlabels.openPicker("Press and hold, or press Alt + Arrow Down, for more reactions").
- The icons, and the name shown above the active option on the core's plain tooltip surface, are hidden from assistive tech (
aria-hidden); the option's name already says it. - In the row, the picked reaction is pressed (
aria-pressed="true") as well as filled withsecondary-container.
Focus
- The button is one Tab stop. A keyboard open moves focus into the row, and closing it with Escape or a keyboard pick puts focus back on the button at once, without scrolling the page.
- Focus isn't trapped: the row is a non-modal popover, and a press anywhere else closes it. Picking with a pointer leaves focus where it was.
- Keyboard focus shows M3's focus indicator on the button and on each option: a 3px
secondaryoutline 2px outside.
Touch target
- The button is 40px tall (
md) or 32px (sm), with an invisible 48 × 48px touch target (TouchTarget). Each option in the row is 48 × 48px. - On touch, a long press opens the row and sliding the finger along it then lifting picks the reaction under it.
Motion
- Under reduced motion the row only fades in and out instead of also scaling from 80%, and the active option is shown at 1.5× at once instead of growing.
- The press ripple appears at full size without growing, and corner changes snap; colours still fade.
What you need to do
- Give every option a
labelin the app's language: it is the option's name, its tooltip and the button's label once picked. - Translate
labels.openPickerandlabels.reactions. - Pick each reaction's
colorfromREACTION_COLORS: the types accept only those roles, each with 4.5:1 on the button and the row. - In forced-colours mode the button keeps a 1px boundary (
Highlightwhen picked,GrayTextwhen disabled), the row keeps a border, and the picked option usesHighlight; keepclassNamesoverrides from removing them.