UI

Reactions

Acknowledge a message or post in one tap, with rolling counts and a compact picker.

import { Reactions } from '@uthereal/ui/reactions'

Reactions playground

Loading interactive preview…

Overview

Reactions renders a standalone bar of reaction pills and an add button that opens a compact picker tray. Each pill pairs a curated icon or short emoji with a tabular rolling count. Reactions chosen by the viewer carry the accent tint and filled icon state; tapping a pill toggles the viewer's reaction and removes the pill when its count reaches zero.

Use Reactions for quick one-tap acknowledgement on posts, comments, or release notes. Use Button for single-tap commands, and use Hold to confirm when an action needs hold friction before committing.

Usage

'use client'
import { useState } from 'react'
import { Reactions, type Reaction } from '@uthereal/ui/reactions'

const options = [
  { id: 'up', label: 'Thumbs up', icon: 'thumbs-up' as const },
  { id: 'sparkle', label: 'Celebrate', icon: 'sparkles' as const },
  { id: 'star', label: 'Star', icon: 'star' as const },
  { id: 'bookmark', label: 'Save', icon: 'bookmark' as const },
]

export function PostReactions() {
  const [value, setValue] = useState<Reaction[]>([
    { id: 'up', count: 12, reacted: true },
    { id: 'sparkle', count: 4, reacted: false },
  ])

  return (
    <Reactions
      options={options}
      value={value}
      onValueChange={setValue}
      action="toggle_reaction"
      onAction={(action) => console.log(action)}
    />
  )
}

Your application owns persistence and side effects. Leave value undefined to let the bar manage state from defaultValue, or pass value and onValueChange to control the list externally. When action is set, onAction fires after every reaction change.

Examples

Use <SchemaPlayground /> above to inspect size, recipe, motion, and theme. The examples below show distinct option formats and starting states.

Emoji options

Each entry in options sets either a curated Lucide icon name (shown in the playground above) or a short emoji string. Emoji options render native text glyphs in both the pill bar and the picker tray.

Empty bar and disabled state

Start with an empty defaultValue to show only the add button until the viewer picks the first reaction. Set disabled to render a read-only bar whose pills and picker trigger are removed from the tab order.

API reference

Serializable schema arguments and defaults come directly from reactionsConfigSchema.

ArgumentType / defaultDescription
labelstringDefault: "Reactions"Accessible name of the reaction bar.
addLabelstringDefault: "Add reaction"Accessible name of the button that opens the picker; also its hover label.
optionsRequiredReactionOption[]—Every reaction the picker offers, in picker order. Each has an id, a label and either a curated icon name or a short emoji.
defaultValueReaction[]Default: []Initial reactions. A reaction whose count reaches zero leaves the bar; later argument edits do not reset a mounted instance.
sizexs | sm | md | lgDefault: "sm"Pill height: 28, 32, 36, or 40 px at xs to lg (Arc pills are compact; sm is the default).
actionstring—Name of an action registered by your application. Sent to onAction after every reaction change.
disabledbooleanDefault: falseEvery pill and the picker unavailable and removed from the tab order.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeReactionsTheme—Color mode, accent, and semantic tokens. See Theming for all keys and defaults.
motionnone | subtle | expressiveDefault: "subtle"Pill and picker animation preset. System reduced-motion preferences take precedence.
motionOptionsReactionsMotionOptions—Press scale (default 0.97) and picker entrance stagger, ms.
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

React integration

PropPurpose
value, onValueChange(next, chg)Controlled reaction list and change callback receiving { id, reacted } in all modes.
onAction(action)Called with the configured action name after every reaction toggle.
renderOptionIcon(name, context)Replaces the Lucide icon for icon-based options (context.slot === 'option').
portalContainerCustom DOM mount target for the portalled picker popover.
presetComponent defaults overridden by explicit instance props.
tokens--ui-* CSS variables applied after the typed theme on the root and picker portal.
refRef to the root <div>.
className, styleAdded to the root <div>. style takes precedence over motion and theme tokens.
Native attributesForwarded <div> attributes including id, aria-*, data-*, and DOM handlers.

Keyboard & accessibility

KeyInteraction
Tab, Shift+TabMoves focus across reaction pills and the add-reaction button.
Enter, Space (pill)Toggles the viewer's reaction on the focused pill.
Enter, Space (add button)Opens or closes the picker tray.
ArrowRight, ArrowLeft, ArrowDown, ArrowUpMoves roving focus across picker options; horizontal arrows mirror in RTL layouts.
Home, End (picker)Moves roving focus to the first or last picker option.
Enter, Space (picker)Toggles the focused option, closes the tray, and returns focus to the add button.
Escape (picker)Closes the picker tray and returns focus to the add button.

The bar renders role="group" with aria-label={label}. Each pill exposes aria-pressed and an accessible label combining the reaction name, count, and viewer state (for example, "Thumbs up, 12 reactions, including yours"). Visual glyphs, rolling digits, hover labels, and picker captions are marked aria-hidden="true". A pre-mounted role="status" live region outside every button announces additions, removals, and updated counts politely.

When a focused pill is toggled to zero and leaves the bar, focus moves automatically to the next pill, the previous pill, or the add button so keyboard users never lose focus to the document body. Setting dir="rtl" (or inheriting RTL from the document) mirrors pill inline padding, tooltip alignment, picker arrow keys, and gliding highlight coordinates. Under forced-colors: active, pills use ButtonText borders, disabled controls use GrayText, chosen pills and picker options use Highlight and HighlightText, and focus rings remain visible.

Motion and theming

Adding a reaction fires a velocity-stacking spring impulse (stiffness: 420, damping: 39) on the glyph so rapid toggles build on existing velocity. Count digits roll vertically on spring.snappy while the count container width follows on spring.morph. Pills enter and exit with a blur-scale fade, reflow on spring.morph (LayoutGroup inside LazyMotion with domMax), and press to 0.97 (0.95 in expressive, overridable via motionOptions.pressScale). When pills wrap onto a new row, bar height springs smoothly on spring.smooth. In the picker tray, options reveal with a stagger (40ms + index * motionOptions.stagger, default 35ms), and a shared highlight glides under the pointer on spring.morph while arrow keys land it immediately.

motion="none" removes all springs, blur, press scale, stagger, and CSS transitions for immediate state updates. prefers-reduced-motion: reduce removes travel, scale, blur, kicks, and springs while keeping a 120ms opacity crossfade.

theme accepts mode, accent, tokens from the core group plus accentStrong, accentSubtle, borderStrong, popupRadius, and shadowRaised, and component geometry tokens pillHeight, addWidth, optionSize, and captionHeight. UtherealProvider supplies application-wide defaults.

Composition

In agent compositions, Reactions is a leaf component. Register its action on the host; the handler receives { componentId }. Reaction counts persist at /components/instance-<id>/value, initialized from defaultValue and preserved across agent edits. See Building with agents.

{
  "type": "Reactions",
  "props": {
    "label": "Release reactions",
    "options": [
      { "id": "up", "label": "Thumbs up", "icon": "thumbs-up" },
      { "id": "sparkle", "label": "Celebrate", "icon": "sparkles" },
      { "id": "star", "label": "Star", "icon": "star" }
    ],
    "defaultValue": [
      { "id": "up", "count": 12, "reacted": true },
      { "id": "sparkle", "count": 4, "reacted": false }
    ],
    "action": "toggle_reaction"
  },
  "children": []
}

On this page