GitHub Primer
JS behaviour
Reaction Bar
Emoji reaction pills with counters and an add-reaction picker. GitHub's 😃🚀👀 shorthand for instant, human feedback.
Real scenarios
The component as it is used in a product — not a specimen grid.
Feedback in one tap, no words needed
Tap a pill to join the crowd — your ring turns blue and the counter moves. The + opens the tray; whatever you pick becomes a brand-new pill.
The same bar, three postures
Compact in list rows, yours with the blue ring, and the lone add-button before anyone dares to react.
23
compact
13
aria-pressed="true"
5
neutral
1
counter
add
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| pill | button | 'emoji + count' | Emoji and a rounded counter in one button; your own reaction gets the blue ring. |
| counter | CounterLabel | 'min-width 20px' | The rounded gray counter; at zero the pill drops out entirely. |
| add | button | 'smiley +' | The + button with an emoji popover; it mints a fresh reaction pill in place. |
| who | tooltip | 'aria-label' | The accessible label names who reacted. |
Snippet
<button class="prr-pill" aria-pressed="false" aria-label="3 people reacted with 🚀">
🚀 <span class="prr-count">3</span>
</button>
<button class="prr-add" aria-label="Add reaction">🙂⁺</button>
<style>
.prr-pill { display: inline-flex; align-items: center; gap: 6px; block-size: 28px;
padding-inline: 10px; border-radius: 2em; border: 1px solid #d1d9e0;
background: transparent; font: 500 13px system-ui; }
.prr-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em;
background: #eff2f5; font-size: 12px; }
.prr-pill[aria-pressed='true'] { border-color: #0969da; }
.prr-pill[aria-pressed='true'] .prr-count { background: #ddf4ff; color: #0969da; }
</style>
// resources/js/Pages/Comments/Show.tsx — reactions toggle against
// the API; Inertia revalidates the comment props afterwards.
import { Head, router } from '@inertiajs/react';
import ReactionBar from '@/components/primer/ReactionBar';
export default function CommentShow() {
return (
<>
<Head title="Release notes · 2.4" />
{/* onToggle={(emoji) => router.post(`/comments/${id}/reactions`, { emoji })} */}
<ReactionBar />
</>
);
}
import { useState } from 'react';
import '@nabuxai/ui-core/css';
type Rx = { e: string; n: number; mine: boolean };
const TRAY = ['👍', '👎', '😄', '🎉', '❤️', '🚀', '👀'];
export default function ReactionBar() {
const [rx, setRx] = useState<Rx[]>([
{ e: '🎉', n: 12, mine: true },
{ e: '🚀', n: 8, mine: false },
]);
const [open, setOpen] = useState(false);
const toggle = (r: Rx) =>
setRx((list) => list.map((x) => (x.e === r.e ? { ...x, mine: !x.mine, n: x.n + (x.mine ? -1 : 1) } : x)));
const pick = (e: string) => {
setRx((list) =>
list.some((x) => x.e === e)
? list.map((x) => (x.e === e ? { ...x, n: x.n + 1, mine: true } : x))
: [...list, { e, n: 1, mine: true }],
);
setOpen(false);
};
return (
<div className="prr-bar">
{rx.filter((r) => r.n > 0).map((r) => (
<button key={r.e} className="prr-pill" aria-pressed={r.mine} aria-label={`${r.n} reactions with ${r.e}`} onClick={() => toggle(r)}>
<span aria-hidden>{r.e}</span><span className="prr-count">{r.n}</span>
</button>
))}
<div className="prr-add">
<button aria-label="Add reaction" aria-expanded={open} onClick={() => setOpen(!open)}>🙂⁺</button>
{open && (
<div className="prr-picker" role="menu" aria-label="Pick a reaction">
{TRAY.map((e) => <button key={e} role="menuitem" aria-label={e} onClick={() => pick(e)}>{e}</button>)}
</div>
)}
</div>
<style>{`
.prr-bar { display: flex; gap: 8px; }
.prr-pill { display: inline-flex; align-items: center; gap: 6px; block-size: 28px; padding-inline: 10px;
border-radius: 2em; border: 1px solid #d1d9e0; background: transparent; font: 500 13px system-ui; }
.prr-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em; background: #eff2f5; font-size: 12px; }
.prr-pill[aria-pressed='true'] { border-color: #0969da; }
.prr-pill[aria-pressed='true'] .prr-count { background: #ddf4ff; color: #0969da; }
`}</style>
</div>
);
}
<!-- ReactionBar.vue -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';
interface Rx { e: string; n: number; mine: boolean }
const TRAY = ['👍', '👎', '😄', '🎉', '❤️', '🚀', '👀'];
const rx = ref<Rx[]>([{ e: '🎉', n: 12, mine: true }, { e: '🚀', n: 8, mine: false }]);
const open = ref(false);
const toggle = (r: Rx) => { r.mine = !r.mine; r.n += r.mine ? 1 : -1; };
const pick = (e: string) => {
const hit = rx.value.find((x) => x.e === e);
if (hit) { hit.n += 1; hit.mine = true } else { rx.value.push({ e, n: 1, mine: true }) }
open.value = false;
};
</script>
<template>
<div class="prr-bar">
<button
v-for="r in rx.filter((x) => x.n > 0)" :key="r.e" class="prr-pill"
:aria-pressed="r.mine" :aria-label="`${r.n} reactions with ${r.e}`" @click="toggle(r)"
>
<span aria-hidden="true">{{ r.e }}</span><span class="prr-count">{{ r.n }}</span>
</button>
<div class="prr-add">
<button aria-label="Add reaction" :aria-expanded="open" @click="open = !open">🙂⁺</button>
<div v-if="open" class="prr-picker" role="menu" aria-label="Pick a reaction">
<button v-for="e in TRAY" :key="e" role="menuitem" :aria-label="e" @click="pick(e)">{{ e }}</button>
</div>
</div>
</div>
</template>
<style scoped>
.prr-bar { display: flex; gap: 8px; }
.prr-pill { display: inline-flex; align-items: center; gap: 6px; block-size: 28px; padding-inline: 10px;
border-radius: 2em; border: 1px solid #d1d9e0; background: transparent; font: 500 13px system-ui; }
.prr-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em; background: #eff2f5; font-size: 12px; }
.prr-pill[aria-pressed='true'] { border-color: #0969da; }
.prr-pill[aria-pressed='true'] .prr-count { background: #ddf4ff; color: #0969da; }
</style>
<!-- ReactionBar.svelte -->
<script lang="ts">
import '@nabuxai/ui-core/css';
interface Rx { e: string; n: number; mine: boolean }
const TRAY = ['👍', '👎', '😄', '🎉', '❤️', '🚀', '👀'];
let rx = $state<Rx[]>([{ e: '🎉', n: 12, mine: true }, { e: '🚀', n: 8, mine: false }]);
let open = $state(false);
const toggle = (r: Rx) => { r.mine = !r.mine; r.n += r.mine ? 1 : -1; };
const pick = (e: string) => {
const hit = rx.find((x) => x.e === e);
if (hit) { hit.n += 1; hit.mine = true } else { rx.push({ e, n: 1, mine: true }) }
open = false;
};
</script>
<div class="prr-bar">
{#each rx.filter((x) => x.n > 0) as r (r.e)}
<button class="prr-pill" aria-pressed={r.mine} aria-label="{r.n} reactions with {r.e}" onclick={() => toggle(r)}>
<span aria-hidden="true">{r.e}</span><span class="prr-count">{r.n}</span>
</button>
{/each}
<div class="prr-add">
<button aria-label="Add reaction" aria-expanded={open} onclick={() => (open = !open)}>🙂⁺</button>
{#if open}
<div class="prr-picker" role="menu" aria-label="Pick a reaction">
{#each TRAY as e (e)}<button role="menuitem" aria-label={e} onclick={() => pick(e)}>{e}</button>{/each}
</div>
{/if}
</div>
</div>
<style>
.prr-bar { display: flex; gap: 8px; }
.prr-pill { display: inline-flex; align-items: center; gap: 6px; block-size: 28px; padding-inline: 10px;
border-radius: 2em; border: 1px solid #d1d9e0; background: transparent; font: 500 13px system-ui; }
.prr-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em; background: #eff2f5; font-size: 12px; }
.prr-pill[aria-pressed='true'] { border-color: #0969da; }
.prr-pill[aria-pressed='true'] .prr-count { background: #ddf4ff; color: #0969da; }
</style>
Shipping this Friday: the PDF export goes live for every workspace, and the report queue clears in under a minute. Chaos-proof your Friday plans accordingly. 🗓️