nook
Browse the docs

Components

Reactions

Built on Base UI

Emoji reactions and an authored, searchable picker with categories and recents.

See the prompt

Jamie Lee

Today at 14:24

The new deployment dashboard is live. Thanks for all the careful reviews this week — rollback is now a single click.

Installation

npx nook-ui@latest add reactions

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Reactions" component to this project, exactly as Nook ships it.

Emoji reactions and an authored, searchable picker with categories and recents.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add reactions`. It writes `components/ui/reactions.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/reactions.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
"use client";
import { Reactions } from "@/components/ui/reactions";
export default function ReactionsDefault() {
  return (
    <article className="grid w-full max-w-xl gap-4">
      <div className="flex items-center gap-3">
        <span
          aria-hidden="true"
          className="flex size-8 items-center justify-center bg-muted text-xs font-semibold"
        >
          JL
        </span>
        <div>
          <p className="text-sm font-medium">Jamie Lee</p>
          <p className="text-xs text-muted-foreground">Today at 14:24</p>
        </div>
      </div>
      <p className="text-sm leading-relaxed">
        The new deployment dashboard is live. Thanks for all the careful reviews
        this week — rollback is now a single click.
      </p>
      <Reactions
        defaultValue={[
          { emoji: "🎉", count: 12, reacted: true },
          { emoji: "👍", count: 8 },
          { emoji: "🚀", count: 4 },
        ]}
      />
    </article>
  );
}
```

API
- `Reactions`: Toggle reactions or open the picker to add one.
  - `value / defaultValue` (`Reaction[]`): emoji, count and reacted; controlled or uncontrolled.
  - `onValueChange` (`(reactions: Reaction[]) => void`): Updated reaction list.
  - `onReact` (`(emoji, reacted) => void`): The reaction that changed.
  - `disabled` (`boolean`): Disables chips and picker.
- `EmojiPicker`: A searchable grid of common emoji.
  - `onEmojiSelect` (`(emoji: string) => void`): Selection callback.
  - `recent / onRecentChange` (`string[] / (recent) => void`): Optional caller-owned recent choices; otherwise local state.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Reaction chips expose counts and aria-pressed. Every emoji has a spoken name. Arrow keys navigate the grid; Home/End jump; Enter selects. Search ArrowDown enters the grid. Popover Escape returns focus.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

"use client";
import { Reactions } from "@/components/ui/reactions";
export default function ReactionsDefault() {
  return (
    <article className="grid w-full max-w-xl gap-4">
      <div className="flex items-center gap-3">
        <span
          aria-hidden="true"
          className="flex size-8 items-center justify-center bg-muted text-xs font-semibold"
        >
          JL
        </span>
        <div>
          <p className="text-sm font-medium">Jamie Lee</p>
          <p className="text-xs text-muted-foreground">Today at 14:24</p>
        </div>
      </div>
      <p className="text-sm leading-relaxed">
        The new deployment dashboard is live. Thanks for all the careful reviews
        this week — rollback is now a single click.
      </p>
      <Reactions
        defaultValue={[
          { emoji: "🎉", count: 12, reacted: true },
          { emoji: "👍", count: 8 },
          { emoji: "🚀", count: 4 },
        ]}
      />
    </article>
  );
}

Examples

Many reactions

Disabled

No reactions yet

Props

Reactions

Toggle reactions or open the picker to add one.

PropTypeDefaultDescription
value / defaultValueReaction[]–emoji, count and reacted; controlled or uncontrolled.
onValueChange(reactions: Reaction[]) => void–Updated reaction list.
onReact(emoji, reacted) => void–The reaction that changed.
disabledboolean–Disables chips and picker.

EmojiPicker

A searchable grid of common emoji.

PropTypeDefaultDescription
onEmojiSelect(emoji: string) => void–Selection callback.
recent / onRecentChangestring[] / (recent) => void–Optional caller-owned recent choices; otherwise local state.

Accessibility

Reaction chips expose counts and aria-pressed. Every emoji has a spoken name. Arrow keys navigate the grid; Home/End jump; Enter selects. Search ArrowDown enters the grid. Popover Escape returns focus.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.