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…
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 this
When
<reaction-bar>
Persistent in-flow bar of curated emoji reactions with counts + own-reaction toggle, attached to an item (comment / post / message).
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.
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.
Basic reaction-bar
1234567891011121314
<reaction-bararia-label="Reactions to comment 482"><buttondata-reaction="thumbsup"data-label="Thumbs up"data-count="3"data-mine>👍</button><buttondata-reaction="rocket"data-label="Rocket"data-count="2">🚀</button><templatedata-palette><buttondata-reaction="thumbsup"data-label="Thumbs up">👍</button><buttondata-reaction="thumbsdown"data-label="Thumbs down">👎</button><buttondata-reaction="laugh"data-label="Laugh">😄</button><buttondata-reaction="hooray"data-label="Hooray">🎉</button><buttondata-reaction="confused"data-label="Confused">😕</button><buttondata-reaction="heart"data-label="Heart">❤️</button><buttondata-reaction="rocket"data-label="Rocket">🚀</button><buttondata-reaction="eyes"data-label="Eyes">👀</button></template></reaction-bar>
State ownership
The component does not track state. Authors own counts + per-user state + persistence. The flow:
User clicks a chip or a palette option.
reaction-bar:toggle fires with { reaction, action, count, mine }. count and mine are the values before the toggle.
The chip turns pending (data-pending + aria-busy="true") and ignores further clicks, so a double click sends one request, not two.
Author makes the backend call.
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.
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.
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.
Toolbar label used when no aria-label is authored.
data-label-dialog
string
Choose a reaction
Label of the palette dialog.
data-label-count-one
string
{count} reaction
Count phrase in chip names for the Intl.PluralRulesone category. {count} is the number formatted with Intl.NumberFormat. Other CLDR categories work the same way (data-label-count-few, -many, ...).
data-label-count-other
string
{count} reactions
Count phrase for every category without its own attribute.
Stable identifier sent to the backend (e.g. thumbsup, heart).
data-count
number
Current count (≥ 1 to show; 0 removes the chip).
data-mine
boolean
Whether the current user has this reaction.
data-label
string
Accessible name of the reaction, on chips and palette buttons (an authored aria-label works too). Defaults to the emoji.
data-pending
boolean
Output: a toggle is in flight. Set on click, cleared by setCount().
Events
Event
Bubbles
Detail
reaction-bar:toggle
yes
{ reaction, action: 'add'|'remove', count, mine } — count and mine are the values before the toggle.
reaction-bar:palette-open
yes
—
reaction-bar:palette-close
yes
—
JavaScript API
Method
Description
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.