Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

Reaction

  • Stable
  • WCAG 2.2 evidence
  • RTL

A reaction under a message, such as a thumbs up, that the user can add or remove. Built on React Aria ToggleButton: a native button with aria-pressed (the user's own reaction), toggled with a click, Enter or Space, with a visible focus ring for keyboard focus (WCAG 2.1.1, 2.4.7, 4.1.2). Its accessible name says what the reaction is and how many people chose it, for example "Thumbs up, 3 reactions"; the visible count is part of it (2.5.3). The pill is 24 px tall, the minimum target size (2.5.8). Selected changes fill and stroke; the brand stroke differs from the default stroke by more than 3:1, and aria-pressed carries the state for assistive technology (1.4.1, 1.4.11). Controlled (isSelected + onChange) or uncontrolled (defaultSelected). Consumer duties: translated label and countLabel; updating count; grouping several reactions in a role="group" with a label such as "Reactions".

import { Reaction } from "@nexera-ui/react";
Loading example…
3
examples
18
props
3
live controls
1
platform
9
WCAG criteria
2
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
label
isSelected
isDisabled
Generated code
import { Reaction } from "@nexera-ui/react";

<Reaction />

Examples 2

The same examples as Storybook, rendered live. Open Code to copy one.

Under a message

Several reactions under a message, in a labelled group; the count follows your own reaction.

Loading example…

Right to left

Right-to-left: the icon moves to the right and the count uses the locale's digits.

Loading example…

Props 18

Press "Try it" on a card to load that prop into the playground.

18 props shown

icon*Nexera
ReactNode

The reaction's icon or emoji, 14 px. Decorative: the accessible name comes from label.

Default –
label*Nexera
string

What the reaction means, in words, for example "Thumbs up". It starts the accessible name ("Thumbs up, 3 reactions"; WCAG 1.1.1, 4.1.2). Translate it.

Default –
count*Nexera
number

Number of people who reacted, shown in the locale's digits and included in the accessible name. Update it in onChange when the user's own reaction is added or removed.

Default –
countLabelNexera
(count: number, formatted: string) => string

Count part of the accessible name, from the number and its locale-formatted text. Translate it, with your locale's plural rules.

Default (count, formatted) => count === 1 ? `${formatted} reaction` : `${formatted} reactions`
idNexera
string

DOM id of the button.

Default –
classNameNexera
string

Extra classes, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style.

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

Default –
isSelectedReact Aria
boolean

Whether the element should be selected (controlled).

Default –
defaultSelectedReact Aria
boolean

Whether the element should be selected (uncontrolled).

Default –
onChangeReact Aria
(isSelected: boolean) => void

Handler that is called when the element's selection state changes.

Default –
isDisabledReact Aria
boolean

Whether the button is disabled.

Default –
onPressReact Aria
(e: PressEvent) => void

Handler that is called when the press is released over the target.

Default –
onPressStartReact Aria
(e: PressEvent) => void

Handler that is called when a press interaction starts.

Default –
onPressEndReact Aria
(e: PressEvent) => void

Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.

Default –
onPressChangeReact Aria
(isPressed: boolean) => void

Handler that is called when the press state changes.

Default –
onPressUpReact Aria
(e: PressEvent) => void

Handler that is called when a press is released over the target, regardless of whether it started on the target or not.

Default –
autoFocusReact Aria
boolean

Whether the element should receive focus on render.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

6 direct · 3 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.1Use of ColorLevel A · supporting test
  • 1.4.11Non-text ContrastLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 2.4.7Focus VisibleLevel AA · tested directly
  • 2.5.3Label in NameLevel A · tested directly
  • 2.5.8Target Size (Minimum)Level AA · supporting test
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

  • data-disabled
  • data-hovered
  • data-pressed
  • data-selected
Usage
<Reaction className="data-disabled:opacity-90 shadow-sm" />

Used in blocks

Related components