ReactionBar
The row of emoji reactions under a message.
View code
<span hidden mix={[reactionSync()]} />
<ReactionBar aria-label="Reactions">
<form method="post" action="/messages/42/reactions">
<input type="hidden" name="emoji" value="🎉" />
<ReactionBar.Reaction emoji="🎉" label="Party popper" count={4} pressed title="You, Mira, Theo and Kenji" />
</form>
<form method="post" action="/messages/42/reactions">
<input type="hidden" name="emoji" value="👀" />
<ReactionBar.Reaction emoji="👀" label="Eyes" count={1} title="Theo" />
</form>
<form method="post" action="/messages/42/reactions">
<input type="hidden" name="emoji" value="🚀" />
<ReactionBar.Reaction emoji="🚀" label="Rocket" count={2} title="Mira and Priya" />
</form>
</ReactionBar>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { ReactionBar } from "@sdxc/ui/chat";Renders the row as a role="group" that wraps onto a second line when a message collects
many reactions, and hides itself while it holds no chip.
Composition
The parts the component publishes, each a static property of the host.
ReactionBarReactionBar.ReactionRenders one reaction chip: a submit button sending the toggle that flips the reader's reaction,aria-pressedwhile they are among its reactors, and its count in tabular figures so the row never shifts.ReactionBar.AddRenders the trailing slot for adding a reaction, where an emoji picker's trigger sits.ReactionBar.TemplateRenders the inert<template>a new chip is cloned from, so a reaction picked from an emoji picker appears in the row at once, posting through the same form a server-drawn chip uses.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
"aria-label" | string | Yes | Names the row for assistive technology, such as "Reactions". |
children | RemixNode | Yes | One form per ReactionBar.Reaction, then an optional ReactionBar.Add and ReactionBar.Template. The row hides while it holds no reaction. |
Also accepts everything in Omit<TagProps<"div">, "aria-label">.
ReactionBar.Reaction
| Prop | Type | Required | Description |
|---|---|---|---|
emoji | string | Yes | The emoji, or the shortcode of a custom one drawn from image. |
image | string | No | A custom emoji's image, drawn in place of the emoji's text. |
label | string | Yes | What the emoji is called, such as "Party popper"; a screen reader hears it before the count. |
count | number | Yes | |
pressed | boolean | No | Whether the reader reacted with this emoji; the chip draws pressed. |
toggle | Toggle | No |
Also accepts everything in Omit<
TagProps<"button">,
"children" | "aria-label" | "name" | "value"
>.
ReactionBar.Add
| Prop | Type | Required | Description |
|---|---|---|---|
children | RemixNode | Yes | The add-reaction control, such as a button opening an emoji picker. |
Also accepts everything in TagProps<"span">.
ReactionBar.Template
| Prop | Type | Required | Description |
|---|---|---|---|
children | RemixNode | Yes | The form a new reaction posts with, holding an <input data-reaction-emoji> for its emoji and one ReactionBar.Reaction; reactionSync() clones and fills it. |