Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

reaction-bar

GitHub-style emoji reaction picker. Persistent in-flow bar of reaction chips with counts + a trigger that opens a curated palette popover.

Overview

<reaction-bar> is a persistent bar of emoji-reaction chips attached to an item (a comment, a post, a message). A single auto-rendered trigger opens a curated palette popover. The component is presentational: authors own the source of truth (counts, per-user state, persistence) and hook the reaction-bar:toggle event to make the backend call.

When to use which primitive

Three adjacent VB primitives sit nearby. The trigger model is the tell — pick the one whose trigger matches your interaction.

Use thisWhen
<reaction-bar>Persistent in-flow bar of curated emoji reactions with counts + own-reaction toggle, attached to an item (comment / post / message).
<selection-menu>Contextual floating toolbar that appears on text selection (anchored to a Range).
<emoji-picker>The user might pick any emoji from the full Unicode catalog (search, categories, recent).
<star-rating>Single-value 1–N rating submitted with a form.

Author surface

Two slots:

  1. Existing chips — direct <button data-reaction data-count [data-mine]> children. The component decorates them with the count, aria-pressed, and a derived aria-label.
  2. Available reactions — inside a <template data-palette> child. The component clones the buttons into a <pop-over> palette once, when the bar upgrades.

The trigger button (😀, change it with data-trigger-icon) is auto-rendered at the end of the bar — you do not author it.

Give each reaction a name with data-label (or aria-label) on both the chip and its palette button. Screen readers announce emoji inconsistently — some say nothing, some read a Unicode name that is not what the reaction means — so the emoji is only the fallback name. Chips that setCount() creates are cloned from the palette button and keep its label.

State ownership

The component does not track state. Authors own counts + per-user state + persistence. The flow:

  1. User clicks a chip or a palette option.
  2. reaction-bar:toggle fires with { reaction, action, count, mine }. count and mine are the values before the toggle.
  3. The chip turns pending (data-pending + aria-busy="true") and ignores further clicks, so a double click sends one request, not two.
  4. Author makes the backend call.
  5. Author updates the bar via bar.setCount(reaction, count, { mine }), which also clears the pending state. If the request fails, call setCount with the old values to roll back.

Nothing changes on screen until setCount runs, so the chip shows the server round-trip as its pending state.

Read-only mode

Set data-disabled for archived threads or other read-only contexts. Chips get aria-disabled="true" and don't toggle, but stay focusable so their counts can still be read. The trigger is disabled and leaves the arrow-key order. The attribute is observed, so adding or removing it later works too.

Accessibility

  • Bar: role="toolbar" with aria-label="Reactions" (override via aria-label on the host).
  • Chips: native buttons; aria-pressed reflects data-mine, so you reacted is announced as the pressed state. Each chip gets a derived aria-label like Thumbs up, 3 reactions built from its data-label (or the emoji) and the count.
  • Trigger: aria-haspopup="dialog", aria-expanded tracks open state.
  • Palette: role="dialog" rendered by <pop-over> in the top layer, holding a group labelled like the bar; Escape closes (handled by pop-over). Opening it moves focus to the first option.
  • Keyboard nav on the bar: Arrow Left / Right move between chips and trigger in visual order (mirrored in right-to-left text; roving tabindex); Home / End jump to ends; Enter / Space activate. setCount() keeps your position.
  • Keyboard nav in the palette: Arrow keys cycle through options; Home / End jump to ends; Enter / Space select.
  • Focus return: after a pick, focus returns to the trigger. When setCount(reaction, 0) removes the focused chip, focus moves to the next chip (or the trigger).
  • Forced colors: a pressed chip is painted with the system Highlight colors, so it stays distinct from unpressed chips.

Localization

Counts are formatted with Intl.NumberFormat and pluralized with Intl.PluralRules for the closest lang. Translate the built-in strings with data-label-* attributes; {count} in a count phrase is replaced by the formatted number.

The chip above is announced as Daumen hoch, 1.500 Reaktionen.

Attributes

AttributeTypeDefaultDescription
aria-labelstringReactionsToolbar label.
data-trigger-iconstring😀Text/emoji content of the trigger button.
data-trigger-labelstringAdd reactionaria-label for the trigger.
data-label-toolbarstringReactionsToolbar label used when no aria-label is authored.
data-label-dialogstringChoose a reactionLabel of the palette dialog.
data-label-count-onestring{count} reactionCount phrase in chip names for the Intl.PluralRules one category. {count} is the number formatted with Intl.NumberFormat. Other CLDR categories work the same way (data-label-count-few, -many, ...).
data-label-count-otherstring{count} reactionsCount phrase for every category without its own attribute.
data-disabledbooleanfalseRead-only mode. Observed.

Chip attributes

AttributeTypeDescription
data-reactionstringStable identifier sent to the backend (e.g. thumbsup, heart).
data-countnumberCurrent count (≥ 1 to show; 0 removes the chip).
data-minebooleanWhether the current user has this reaction.
data-labelstringAccessible name of the reaction, on chips and palette buttons (an authored aria-label works too). Defaults to the emoji.
data-pendingbooleanOutput: a toggle is in flight. Set on click, cleared by setCount().

Events

EventBubblesDetail
reaction-bar:toggleyes{ reaction, action: 'add'|'remove', count, mine } — count and mine are the values before the toggle.
reaction-bar:palette-openyes—
reaction-bar:palette-closeyes—

JavaScript API

MethodDescription
setCount(reaction, count, { mine })Update a chip after the server confirms, and clear its pending state. Creates the chip from the palette template button if it doesn't exist yet; removes the chip when count drops to 0.
openPalette()Open the palette popover programmatically (no-op while data-disabled).
closePalette()Close it.

See also

  • <selection-menu> — floating toolbar that anchors to text selection.
  • <emoji-picker> — full Unicode emoji browser with search + categories.
  • <star-rating> — single-value form-associated rating.
  • <pop-over> — the surface this component composes for the palette.
↑