SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

ReactionBar

The row of emoji reactions under a message.

View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
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.

  • ReactionBar
  • ReactionBar.ReactionRenders one reaction chip: a submit button sending the toggle that flips the reader's reaction, aria-pressed while 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.

PropTypeRequiredDescription
"aria-label"stringYesNames the row for assistive technology, such as "Reactions".
childrenRemixNodeYesOne 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

PropTypeRequiredDescription
emojistringYesThe emoji, or the shortcode of a custom one drawn from image.
imagestringNoA custom emoji's image, drawn in place of the emoji's text.
labelstringYesWhat the emoji is called, such as "Party popper"; a screen reader hears it before the count.
countnumberYes
pressedbooleanNoWhether the reader reacted with this emoji; the chip draws pressed.
toggleToggleNo

Also accepts everything in Omit< TagProps<"button">, "children" | "aria-label" | "name" | "value" >.

ReactionBar.Add

PropTypeRequiredDescription
childrenRemixNodeYesThe add-reaction control, such as a button opening an emoji picker.

Also accepts everything in TagProps<"span">.

ReactionBar.Template

PropTypeRequiredDescription
childrenRemixNodeYesThe form a new reaction posts with, holding an <input data-reaction-emoji> for its emoji and one ReactionBar.Reaction; reactionSync() clones and fills it.
@sdxc/ui

Can’t find it? Contact us