# Reply bar

> A pill of post actions and a black plus that merge into one reply field, the plus turning into its send button.

The row under a post: a soft white pill with reply, emoji and like, and a black plus beside it. Press reply and the two become one: the pill stretches over the plus into a text field with the caret ready, and a black send button comes into focus inside its right end while the plus blurs away. Type and press Enter, and the plane flies off, a check lands and the bar folds back. The heart pops when you like the post, and the emoji opens a small row of six that start a reply with the one you pick.

A React component by Bruno Delorence: https://brunodelorence.com/components/reply-bar. MIT License, Copyright (c) 2026 Bruno Delorence.

Category: Inputs.

## Anatomy

1. **Pill**: A soft white pill, 178 × 56 px closed. Open, it stretches to 296 px and becomes the field.
2. **Reply**: Opens the field and focuses it. Open, its bubble stays as the field’s icon, 5.5 px further left.
3. **Emoji**: Opens a row of six emoji; the one picked opens the field with it typed in.
4. **Like**: A toggle button (`aria-pressed`): the heart fills and pops.
5. **Plus**: The black button beside the pill, 81 × 53 px: the bigger target for the same action, starting a reply.

## Properties

### Placeholder (`placeholder`)

1. **Write a reply (default)**: Under a post or a comment.
2. **Add a comment**: Under a photo or a document.

Say what the words will be, in three or four words. The field is 156 px wide before the send button; longer placeholders are cut.

## When to use

- The actions under a post, a photo or a comment in a feed: reply, react and like, in one compact row.
- Short replies written in place, one line long, where opening a full editor would break the reading.
- A layout with no room to spare: the open field takes exactly the width of the closed pill and plus, so nothing around it moves.

## When not to use

- Long or formatted replies, with attachments, mentions or several paragraphs. Open a composer with a multi-line field.
- A chat, where the field should always be open and ready. Use a plain message field.
- More than three actions under the post: the pill is drawn for three. Use a toolbar or an overflow menu.
- Pages that must stay still. With reduced motion the swap is instant, but a static field and buttons are lighter.

### Opening and closing

- **Reply or the plus** opens the field and puts the focus in it; so does an emoji picked from the picker, typed in.
- **Enter or the send button** sends: the plane flies off, a check lands, and the bar folds 700 ms later.
- **Escape** folds it and keeps the draft; **leaving it empty** folds it too. A field with words in it stays open when the focus leaves.
- **With reduced motion** the two states swap at once, without the spring, the blur or the pop.

## Do’s and don’ts

- **Do**: Keep it for one-line replies, where writing in place is faster than opening a composer.
- **Don’t**: Use a long placeholder: past about 156 px it is cut under the send button.

## Content

The words are the placeholder and the buttons’ names for screen readers.

- **A short placeholder in sentence case**, no full stop: `Write a reply`, `Add a comment`.
- **Button names that say the action**: `Reply`, `Add an emoji`, `Like`, `New reply`, `Send reply`.

## Installation

Install it with the shadcn CLI, into components/reply-bar of any React project:

```sh
npx shadcn@latest add https://brunodelorence.com/r/reply-bar.json
```

Or add the registry to components.json once, as a namespace that coding agents and the shadcn MCP server search by name:

```json
{
  "registries": {
    "@brunodelorence": "https://brunodelorence.com/r/{name}.json"
  }
}
```

```sh
npx shadcn@latest add @brunodelorence/reply-bar
```

Or copy all the source files below into one folder of your project. Either way it needs React 19.2 and a bundler with CSS Modules (Next.js, Vite).

It has a dark colour scheme. Its colours are CSS light-dark() pairs, kept inside @supports so that builds which rewrite light-dark() for older browsers leave them alone: it follows your page’s color-scheme (light unless the page sets one) or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

## Usage

```tsx
import { ReplyBar } from './reply-bar';

export function PostActions({ postId }: { postId: string }) {
  return (
    <ReplyBar
      autoplay={false}
      onSend={(text) => postReply(postId, text)}
      onLikeChange={(liked) => saveLike(postId, liked)}
    />
  );
}
```

## States

- **Closed**: The default: three icons in the pill, the black plus 37 px to its right.
- **Liked**: The heart filled in its colour; the button says it is pressed.
- **Open**: The field, focused, with its placeholder, and the send button inside its right end.
- **Draft**: Words typed and kept: a blur or Escape leaves the draft for the next opening.
- **Dark**: With `colorScheme="dark"`: a graphite pill on a near-black stage; the black button turns near-white.

## How it works

- One morph, two pieces: the pill is 178 × 56 px closed and 296 px open, exactly as wide as pill, 37 px gap and 81 × 53 px plus together, so nothing around the bar moves.
- Only the pill’s width is animated, on a spring written as a CSS linear() easing: damping 0.8 at 17 rad/s opening (a 1.5% overshoot, 460 ms), 0.9 at 19 rad/s closing (400 ms). The 76 × 47 px send button is pinned 4.5 px inside the pill’s right end, so it rides the edge with no animation of its own.
- Everything that comes or goes cross-fades through a blur: the emoji and heart drift 9 px left and blur out in 150 ms; the placeholder blurs in from 6 px, 7 px to its right, 80 ms later; the plus blurs to 8 px and slides 15 px right as the send button sharpens. Each direction has its own timings, set on the state it enters, so closing is never a rewound opening.
- Opening focuses the field once it stops being inert; Enter or send submits, the plane flies 14 px up and right while a check springs in, and the bar folds 700 ms later. Escape folds it and keeps the draft; a blur with nothing typed folds it too.
- A like remounts the heart, so its 420 ms pop (down to 76%, up to 124%) and the ring that bursts from it play again each time.
- While on screen and untouched, a demo pointer opens the field, types a reply letter by letter with a drawn caret (the real field is never focused, so the page never scrolls), sends it and likes the post; any input from the reader stops it.
- Every colour is a token on the root, light-dark() where the two schemes differ: at night the pill turns graphite and the black button near-white, so it stays the strongest mark.

## API reference

- **placeholder** (`string`, default `'Write a reply'`): The field’s placeholder; keep it to about 156 px of text.
- **defaultValue** (`string`, default `''`): A draft already in the field.
- **defaultLiked** (`boolean`, default `false`): Starts with the heart filled.
- **defaultOpen** (`boolean`, default `false`): Starts with the field open, as a still for docs and screenshots; it turns the autoplay demo off.
- **emojis** (`readonly string[]`): The emoji the picker offers, up to six; a thumbs up, laughter, heart eyes, fire, clapping and a party popper by default.
- **onSend** (`(text: string) => void`): Called with the trimmed reply when it is sent.
- **onLikeChange** (`(liked: boolean) => void`): Called when the reader likes or unlikes.
- **autoplay** (`boolean`, default `true`): While on screen and untouched, a demo pointer writes and sends a reply and likes the post; any input from the reader stops it.
- **colorScheme** (`'light' | 'dark' | 'system'`): Light or dark colours, or the reader’s; without it, the page’s color-scheme.
- **className** (`string`): A class for the stage.

## Accessibility

### Keyboard

- Tab reaches Reply, Emoji, Like and the plus. Enter or Space on Reply or the plus opens the field with the focus in it.
- In the field, Enter sends and Escape folds the bar, the focus going back to Reply.
- The emoji picker opens with the focus on its first emoji; arrows, Home and End move, Enter picks, Escape goes back to the emoji button.

### Screen readers

- Reply and the plus have `aria-expanded` and `aria-controls` on the field; Like is a toggle with `aria-pressed`.
- What is out of view is inert: the field and send while closed, the icons and the plus while open.
- A polite live region says “Reply sent”.

### Target size

The icon buttons are 52 × 50 px, the plus 81 × 53 and the send 76 × 47, all over 44 px (WCAG 2.5.5, AAA).

### In this build

- Reply, Add an emoji, Like and New reply are buttons with their own names; Reply and New reply carry aria-expanded and aria-controls on the field, Like is a toggle with aria-pressed.
- Opening moves the focus into the field; Enter sends, Escape folds the bar and the focus goes back to Reply.
- The emoji picker opens with the focus on its first emoji; arrows, Home and End move, Enter picks and opens the field with it, Escape returns to the emoji button.
- What is out of view is inert: the field and send button while closed, the icons and the plus while open.
- A polite live region says “Reply sent”. Every control shows a focus ring on keyboard focus; the icons and the demo pointer are hidden from screen readers.
- With reduced motion the two states swap at once, without the spring, blur, pop or burst, and the demo does not play.

## Source

### reply-bar/reply-bar.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import {
  useEffect,
  useEffectEvent,
  useId,
  useLayoutEffect,
  useRef,
  useState,
  type CSSProperties,
  type KeyboardEvent as ReactKeyboardEvent,
} from 'react';
import { DemoPointer, runDemo, type Point } from './demo-pointer';
import { CheckIcon, CommentIcon, EmojiIcon, HeartIcon, PlusIcon, SendIcon } from './icons';
import { useAutoplay } from './use-autoplay';
import styles from './reply-bar.module.css';

/*
 * Reply bar: the actions under a post, a soft white pill of three icons (reply, emoji, like) and
 * a black plus beside it. Reply (or the plus) turns the two into one: the pill stretches over the
 * plus into a text field, and a black send button grows into its right end while the plus fades
 * away. Sending, Escape, or leaving it empty folds it back.
 *
 * - One morph, two pieces. The pill is 178 × 56 px closed and 296 px open, as wide as pill and
 *   plus together, so nothing around it moves. Its width rides a spring (CSS linear() easings in
 *   the stylesheet); the send button is pinned 4.5 px inside its right end, so it travels with
 *   the edge instead of being animated on its own.
 * - Everything that comes and goes cross-fades through a blur: the emoji and the heart drift left
 *   and blur out, the placeholder blurs in from 7 px to its right, the plus blurs away to the
 *   right as the send button comes into focus. Each direction has its own timings, set on the
 *   state it enters.
 * - Real behaviour: opening focuses the field; Enter or send submits (the plane flies off, a check
 *   lands, and the bar folds after 700 ms); Escape closes and keeps the draft; a blur with nothing
 *   typed closes. The heart toggles with a pop; the emoji opens a row of six to pick from, and the
 *   pick opens the field with it typed in.
 * - While on screen and untouched, a demo pointer opens the field, types a reply, sends it and
 *   likes the post. The reader's first input stops it for good.
 */

const EMOJIS = ['👍', '😂', '😍', '🔥', '👏', '🎉'] as const;
const EMOJI_NAMES: Record<string, string> = {
  '👍': 'Thumbs up',
  '😂': 'Tears of joy',
  '😍': 'Heart eyes',
  '🔥': 'Fire',
  '👏': 'Clapping',
  '🎉': 'Party popper',
};
/** How long the sent check shows before the bar folds. */
const SENT_HOLD = 700;
/** Where the field's text starts, in px from the pill's left edge (the fake caret's origin). */
const TEXT_LEFT = 52;

export function ReplyBar({
  placeholder = 'Write a reply',
  defaultValue = '',
  defaultLiked = false,
  defaultOpen = false,
  emojis = EMOJIS,
  onSend,
  onLikeChange,
  autoplay = true,
  colorScheme,
  className = '',
}: {
  /** The field's placeholder. */
  placeholder?: string;
  /** Text already in the field, as a draft. */
  defaultValue?: string;
  /** Starts with the heart filled. */
  defaultLiked?: boolean;
  /** Starts open, as a still for docs and screenshots; it also turns the autoplay demo off. */
  defaultOpen?: boolean;
  /** The emoji the picker offers, six or fewer. */
  emojis?: readonly string[];
  /** Called with the trimmed reply when it is sent. */
  onSend?: (text: string) => void;
  /** Called when the reader likes or unlikes. */
  onLikeChange?: (liked: boolean) => void;
  /** While on screen and untouched, a demo pointer writes and sends a reply. */
  autoplay?: boolean;
  /** Light or dark colours, or the reader's ('system'); without it, the page's color-scheme. */
  colorScheme?: 'light' | 'dark' | 'system';
  className?: string;
}) {
  const { ref: root, playing, take } = useAutoplay<HTMLDivElement>();
  const [open, setOpen] = useState(defaultOpen);
  const [value, setValue] = useState(defaultValue);
  const [liked, setLiked] = useState(defaultLiked);
  /** Counts likes, so each one remounts the heart and plays its pop again. */
  const [pops, setPops] = useState(0);
  const [picker, setPicker] = useState(false);
  const [sent, setSent] = useState(false);
  /** The demo's stand-ins for a hover and a focused field's caret. */
  const [hover, setHover] = useState<'comment' | 'heart' | 'send' | null>(null);
  const [fakeCaret, setFakeCaret] = useState(false);
  const [caretX, setCaretX] = useState(TEXT_LEFT);
  const [message, setMessage] = useState('');

  const pickerId = useId();
  const inputId = useId();
  const input = useRef<HTMLInputElement>(null);
  const comment = useRef<HTMLButtonElement>(null);
  const emojiButton = useRef<HTMLButtonElement>(null);
  const heart = useRef<HTMLButtonElement>(null);
  const send = useRef<HTMLButtonElement>(null);
  const bar = useRef<HTMLDivElement>(null);
  const items = useRef<(HTMLButtonElement | null)[]>([]);
  const mirror = useRef<HTMLSpanElement>(null);
  const pointer = useRef<HTMLSpanElement>(null);
  const openRef = useRef(defaultOpen);
  const openedBy = useRef<'reader' | 'demo'>('reader');
  const focusNext = useRef(false);
  const refocusNext = useRef(false);
  const sentTimer = useRef(0);

  /** Repeats are made to differ, so screen readers announce them again. */
  const announce = (text: string) => setMessage((now) => (now === text ? `${text} ` : text));

  const openField = (by: 'reader' | 'demo') => {
    setPicker(false);
    openedBy.current = by;
    focusNext.current = by === 'reader';
    if (openRef.current) {
      // Already open (an emoji picked from a stale picker): just take the focus.
      if (by === 'reader') input.current?.focus();
      return;
    }
    openRef.current = true;
    setOpen(true);
  };

  /** Folds the bar; `refocus` puts the focus back on Reply, for a close from the keyboard. */
  const closeField = (refocus: boolean) => {
    if (!openRef.current) return;
    openRef.current = false;
    setOpen(false);
    setFakeCaret(false);
    // Reply is inert until the bar has folded, so it takes the focus after the render.
    refocusNext.current = refocus;
  };

  const submit = (by: 'reader' | 'demo') => {
    if (sent) return;
    const text = value.trim();
    if (!text) {
      input.current?.focus();
      return;
    }
    setSent(true);
    if (by === 'reader') {
      onSend?.(text);
      announce('Reply sent');
    }
    const refocus = bar.current?.contains(document.activeElement) ?? false;
    window.clearTimeout(sentTimer.current);
    sentTimer.current = window.setTimeout(() => {
      setSent(false);
      setValue('');
      closeField(refocus);
    }, SENT_HOLD);
  };

  const toggleLike = (by: 'reader' | 'demo') => {
    const next = !liked;
    setLiked(next);
    if (next) setPops((count) => count + 1);
    if (by === 'reader') onLikeChange?.(next);
  };

  // A close from the keyboard hands the focus back to Reply, once it is no longer inert.
  useLayoutEffect(() => {
    if (open || !refocusNext.current) return;
    refocusNext.current = false;
    comment.current?.focus({ preventScroll: true });
  }, [open]);

  // The field gets the focus once it is no longer inert, with the caret after any draft.
  useLayoutEffect(() => {
    if (!open || !focusNext.current) return;
    focusNext.current = false;
    const field = input.current;
    if (!field) return;
    field.focus({ preventScroll: true });
    field.setSelectionRange(field.value.length, field.value.length);
  }, [open, value]);

  // The demo's caret stands after the words, measured from a hidden copy of them.
  useLayoutEffect(() => {
    if (!fakeCaret) return;
    setCaretX(TEXT_LEFT + (mirror.current?.offsetWidth ?? 0));
  }, [fakeCaret, value]);

  // A press anywhere else closes the picker.
  useEffect(() => {
    if (!picker) return;
    const onDown = (event: PointerEvent) => {
      if (!bar.current?.contains(event.target as Node)) setPicker(false);
    };
    document.addEventListener('pointerdown', onDown);
    return () => document.removeEventListener('pointerdown', onDown);
  }, [picker]);

  // The picker takes the focus on its first emoji when it opens; it is a short row of buttons.
  useEffect(() => {
    if (picker) items.current[0]?.focus({ preventScroll: true });
  }, [picker]);

  useEffect(() => () => window.clearTimeout(sentTimer.current), []);

  // The demo: open, type, send; like the post; then open and leave it again.
  const demoAct = useEffectEvent(
    (
      act:
        | { hover: 'comment' | 'heart' | 'send' | null }
        | { open: true }
        | { type: string }
        | { send: true }
        | { like: true }
        | { close: true }
        | { stop: true },
    ) => {
      if ('hover' in act) setHover(act.hover);
      else if ('open' in act) {
        openField('demo');
        setFakeCaret(true);
      } else if ('type' in act) setValue(act.type);
      else if ('send' in act) submit('demo');
      else if ('like' in act) toggleLike('demo');
      else if ('close' in act) closeField(false);
      // The demo only folds what it opened: the reader may be opening it as the demo stops.
      else {
        setHover(null);
        setFakeCaret(false);
        if (openedBy.current === 'demo' && openRef.current) {
          window.clearTimeout(sentTimer.current);
          setSent(false);
          setValue('');
          closeField(false);
        }
      }
    },
  );
  const demo = autoplay && !defaultOpen && playing;
  useEffect(() => {
    const stage = root.current;
    const arrow = pointer.current;
    if (!demo || !stage || !arrow) return;
    const stop = runDemo(stage, arrow, async ({ wait, glide, glyph }) => {
      /** A point on `element`, as shares of its box, in the stage's own px. */
      const on = (element: HTMLElement | null, x = 0.5, y = 0.5): Point => {
        const frame = stage.getBoundingClientRect();
        const scale = frame.width / stage.offsetWidth || 1;
        const rect = (element ?? stage).getBoundingClientRect();
        return {
          x: (rect.left + rect.width * x - frame.left) / scale,
          y: (rect.top + rect.height * y - frame.top) / scale,
        };
      };
      /** Below the bar, where the pointer rests out of the way. */
      const rest = () => {
        const point = on(bar.current, 0.55, 0.5);
        return { x: point.x, y: point.y + 64 };
      };
      const press = async (target: 'comment' | 'heart' | 'send', element: HTMLElement | null) => {
        await glide(on(element, 0.58, 0.62), 640);
        glyph('hand');
        demoAct({ hover: target });
        await wait(380);
      };
      const words = ['Love this one', 'Saving this for later'];
      await glide(rest(), 700);
      for (let round = 0; ; round += 1) {
        await wait(900);
        await press('comment', comment.current);
        demoAct({ open: true });
        demoAct({ hover: null });
        glyph('arrow');
        await wait(260);
        await glide(rest(), 560);
        await wait(500);
        const text = words[round % words.length];
        for (let i = 1; i <= text.length; i += 1) {
          demoAct({ type: text.slice(0, i) });
          await wait(text[i - 1] === ' ' ? 120 : 62);
        }
        await wait(520);
        await press('send', send.current);
        demoAct({ send: true });
        demoAct({ hover: null });
        await wait(SENT_HOLD + 500);
        glyph('arrow');
        await glide(rest(), 520);
        await wait(800);
        if (round % 2 === 0) {
          await press('heart', heart.current);
          demoAct({ like: true });
          await wait(700);
          demoAct({ hover: null });
          glyph('arrow');
          await glide(rest(), 560);
          await wait(1400);
        } else {
          // The post is unliked again, so the next round's like pops.
          await press('heart', heart.current);
          demoAct({ like: true });
          demoAct({ hover: null });
          glyph('arrow');
          await glide(rest(), 560);
          await wait(1000);
        }
      }
    });
    return () => {
      stop();
      demoAct({ stop: true });
    };
  }, [demo, root]);

  const onInputKey = (event: ReactKeyboardEvent<HTMLInputElement>) => {
    if (event.key === 'Enter' && !event.nativeEvent.isComposing) {
      event.preventDefault();
      submit('reader');
    } else if (event.key === 'Escape') {
      event.preventDefault();
      closeField(true);
    }
  };

  const onPickerKey = (event: ReactKeyboardEvent) => {
    const index = items.current.findIndex((element) => element === document.activeElement);
    const count = emojis.length;
    const move = (next: number) => {
      event.preventDefault();
      items.current[(next + count) % count]?.focus();
    };
    if (event.key === 'ArrowRight' || event.key === 'ArrowDown') move(index + 1);
    else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') move(index - 1);
    else if (event.key === 'Home') move(0);
    else if (event.key === 'End') move(count - 1);
    else if (event.key === 'Escape') {
      event.preventDefault();
      setPicker(false);
      emojiButton.current?.focus();
    } else if (event.key === 'Tab') setPicker(false);
  };

  const pick = (emoji: string) => {
    setValue((now) => (now && !now.endsWith(' ') ? `${now} ${emoji}` : `${now}${emoji}`));
    openField('reader');
  };

  return (
    <div
      ref={root}
      className={`${styles.root} ${className}`}
      data-part="stage"
      data-open={open}
      data-sent={sent}
      data-color-scheme={colorScheme}
      onPointerDownCapture={take}
      onKeyDownCapture={take}
      onPointerMove={(event) => {
        if (event.pointerType !== 'touch') take();
      }}
    >
      <div ref={bar} className={styles.bar} data-part="bar">
        <div className={styles.field} data-part="field">
          <div className={styles.tools} role="group" aria-label="Post actions" inert={open}>
            <button
              ref={comment}
              type="button"
              className={styles.tool}
              data-part="reply"
              data-hover={hover === 'comment'}
              aria-label="Reply"
              aria-expanded={open}
              aria-controls={inputId}
              onClick={() => openField('reader')}
            >
              <CommentIcon className={styles.icon} />
            </button>
            <button
              ref={emojiButton}
              type="button"
              className={`${styles.tool} ${styles.fades}`}
              data-part="emoji"
              aria-label="Add an emoji"
              aria-haspopup="true"
              aria-expanded={picker}
              aria-controls={pickerId}
              onClick={() => setPicker((now) => !now)}
            >
              <EmojiIcon className={styles.icon} />
            </button>
            <button
              ref={heart}
              type="button"
              className={`${styles.tool} ${styles.fades}`}
              data-part="like"
              data-hover={hover === 'heart'}
              data-liked={liked}
              aria-label="Like"
              aria-pressed={liked}
              onClick={() => toggleLike('reader')}
            >
              <span key={pops} className={styles.heart} data-pop={pops > 0 && liked}>
                <HeartIcon className={styles.icon} />
              </span>
              {pops > 0 && liked && <span key={`b${pops}`} className={styles.burst} />}
            </button>
          </div>

          <input
            ref={input}
            id={inputId}
            className={styles.input}
            data-part="input"
            type="text"
            value={value}
            placeholder={placeholder}
            aria-label="Reply"
            autoComplete="off"
            enterKeyHint="send"
            readOnly={sent}
            inert={!open}
            onChange={(event) => setValue(event.target.value)}
            onKeyDown={onInputKey}
            onBlur={(event) => {
              if (sent || bar.current?.contains(event.relatedTarget as Node | null)) return;
              if (!event.currentTarget.value.trim()) closeField(false);
            }}
          />
          <span ref={mirror} className={styles.mirror} aria-hidden="true">
            {value}
          </span>
          {fakeCaret && open && !sent && (
            <span
              className={styles.caret}
              style={{ '--x': `${caretX}px` } as CSSProperties}
              aria-hidden="true"
            />
          )}

          <button
            ref={send}
            type="button"
            className={styles.send}
            data-part="send"
            data-hover={hover === 'send'}
            aria-label="Send reply"
            inert={!open}
            onClick={() => submit('reader')}
          >
            <SendIcon className={`${styles.glyph} ${styles.plane}`} />
            <CheckIcon className={`${styles.glyph} ${styles.check}`} />
          </button>
        </div>

        <button
          type="button"
          className={styles.action}
          data-part="plus"
          aria-label="New reply"
          aria-controls={inputId}
          aria-expanded={open}
          inert={open}
          onClick={() => openField('reader')}
        >
          <PlusIcon className={styles.glyph} />
        </button>

        <div
          id={pickerId}
          className={styles.picker}
          data-part="picker"
          data-shown={picker && !open}
          role="toolbar"
          aria-label="Emoji"
          inert={!picker || open}
          onKeyDown={onPickerKey}
        >
          {emojis.slice(0, 6).map((emoji, index) => (
            <button
              key={emoji}
              ref={(element) => {
                items.current[index] = element;
              }}
              type="button"
              className={styles.emoji}
              aria-label={EMOJI_NAMES[emoji] ?? emoji}
              tabIndex={index === 0 ? 0 : -1}
              onClick={() => pick(emoji)}
            >
              <span aria-hidden="true">{emoji}</span>
            </button>
          ))}
        </div>
      </div>

      <p className={styles.hidden} aria-live="polite">
        {message}
      </p>
      <div className={styles.pointerLayer} aria-hidden="true">
        <DemoPointer
          ref={pointer}
          className={styles.pointer}
          arrowClass={styles.arrow}
          handClass={styles.hand}
        />
      </div>
    </div>
  );
}
```

### reply-bar/reply-bar.module.css

```css
/* Reply bar (reply-bar.tsx): on a quiet grey stage, a soft white pill of three icons and a black
   plus beside it, 296 × 56 px together. Open, the pill is a 296 px text field with the black send
   button inside its right end.

   Motion. The pill's width moves on springs written as linear() easings: a softer one that opens
   (damping 0.8, 17 rad/s: a 1.5% overshoot, 460 ms) and a firmer one that closes (0.9, 19 rad/s,
   400 ms). What comes and goes cross-fades through a blur, each direction with its own timing,
   set on the state it enters.

   Colours are the tokens below, light-dark(light, dark) where the two differ: the component takes
   the color-scheme it inherits from the page, or the one its colorScheme prop sets. In the dark
   the black button turns near-white, so it stays the strongest thing on the stage. */

.root {
  --stage: #f0f0f0;
  --line: rgb(0 0 0 / 0.05);
  /* The pill: a white that greys a little toward its foot, a hairline edge and a soft lift. */
  --pill-top: #fff;
  --pill-foot: #f6f6f6;
  --pill-edge: rgb(0 0 0 / 0.075);
  --pill-edge-focus: rgb(0 0 0 / 0.16);
  --pill-shadow: rgb(0 0 0 / 0.06);
  --pill-glow: #fff;
  --ink: #1c1c1e;
  --placeholder: #8a8a8e;
  --chip: rgb(0 0 0 / 0.055);
  /* The black button and its ink. */
  --action: #111112;
  --action-ink: #fff;
  --action-edge: rgb(255 255 255 / 0.14);
  --action-shadow: rgb(0 0 0 / 0.18);
  --heart: #f0335a;
  --focus: #387bff;
  --pointer: #1c1c1e;
  --pointer-edge: #fff;
  --pointer-shadow: rgb(0 0 0 / 0.25);
  --open-spring: linear(
    0,
    0.0446,
    0.1494,
    0.2814,
    0.4187,
    0.5479,
    0.6616,
    0.757,
    0.8335,
    0.8926,
    0.9365,
    0.9677,
    0.9889,
    1.0024,
    1.0103,
    1.0141,
    1.0152,
    1.0146,
    1.013,
    1.011,
    1.009,
    1.007,
    1.0052,
    1.0038,
    1
  );
  --close-spring: linear(
    0,
    0.0575,
    0.184,
    0.3321,
    0.4759,
    0.6026,
    0.7076,
    0.7908,
    0.8544,
    0.9015,
    0.9355,
    0.9593,
    0.9755,
    0.9862,
    0.9931,
    0.9972,
    0.9996,
    1.0009,
    1.0014,
    1.0015,
    1
  );
  --open-time: 460ms;
  --close-time: 400ms;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 300px;
  max-height: 520px;
  overflow: hidden;
  overflow: clip;
  border-radius: 18px;
  background: var(--stage);
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
@supports (color: light-dark(#fff, #000)) {
  .root {
    --stage: light-dark(#f0f0f0, #131315);
    --line: light-dark(rgb(0 0 0 / 0.05), rgb(255 255 255 / 0.06));
    --pill-top: light-dark(#fff, #2a2a2e);
    --pill-foot: light-dark(#f6f6f6, #222225);
    --pill-edge: light-dark(rgb(0 0 0 / 0.075), rgb(255 255 255 / 0.09));
    --pill-edge-focus: light-dark(rgb(0 0 0 / 0.16), rgb(255 255 255 / 0.2));
    --pill-shadow: light-dark(rgb(0 0 0 / 0.06), rgb(0 0 0 / 0.45));
    --pill-glow: light-dark(#fff, rgb(255 255 255 / 0.06));
    --ink: light-dark(#1c1c1e, #ededf0);
    --placeholder: light-dark(#8a8a8e, #8e8e94);
    --chip: light-dark(rgb(0 0 0 / 0.055), rgb(255 255 255 / 0.08));
    --action: light-dark(#111112, #f2f2f4);
    --action-ink: light-dark(#fff, #111112);
    --action-edge: light-dark(rgb(255 255 255 / 0.14), rgb(0 0 0 / 0.08));
    --action-shadow: light-dark(rgb(0 0 0 / 0.18), rgb(0 0 0 / 0.5));
    --heart: light-dark(#f0335a, #ff4d70);
    --focus: light-dark(#387bff, #6b9dff);
  }
}
.root[data-color-scheme='light'] {
  color-scheme: light;
}
.root[data-color-scheme='dark'] {
  color-scheme: dark;
}
.root[data-color-scheme='system'] {
  color-scheme: light dark;
}

/* The two pieces' footprint: pill and plus closed, the field open; the same 296 px either way. */
.bar {
  position: relative;
  width: 296px;
  height: 56px;
}

/* The white pill, and later the field. Its width is the morph; the rest rides on it. */
.field {
  position: absolute;
  top: 0;
  left: 0;
  width: 178px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(var(--pill-top) 30%, var(--pill-foot));
  box-shadow:
    inset 0 0 0 1px var(--pill-edge),
    inset 0 1.5px 0 var(--pill-glow),
    0 1px 2px var(--pill-shadow),
    0 8px 22px var(--pill-shadow);
  transition:
    width var(--close-time) var(--close-spring),
    box-shadow 0.2s ease;
}
.root[data-open='true'] .field {
  width: 296px;
  transition:
    width var(--open-time) var(--open-spring),
    box-shadow 0.2s ease;
}
.field:has(.input:focus) {
  box-shadow:
    inset 0 0 0 1px var(--pill-edge-focus),
    inset 0 1.5px 0 var(--pill-glow),
    0 1px 2px var(--pill-shadow),
    0 8px 22px var(--pill-shadow);
}

/* The three icons, 52 px apart: their middles at 37, 89 and 141 px. */
.tools {
  position: absolute;
  top: 3px;
  left: 11px;
  display: flex;
  height: 50px;
}
.tool {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 50px;
  padding: 0;
  border: 0;
  border-radius: 25px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition:
    opacity 0.22s ease-out 0.09s,
    filter 0.22s ease-out 0.09s,
    transform var(--close-time) var(--close-spring);
}
/* The hover chip: a soft pill a little wider than the button, as the first one is drawn. */
.tool::before {
  content: '';
  position: absolute;
  inset: 0 -4px;
  border-radius: inherit;
  background: var(--chip);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tool:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}
.icon {
  position: relative;
  display: block;
  width: 24px;
  height: 24px;
  transition: transform 0.15s ease;
}
.tool:active .icon {
  transform: scale(0.9);
}
@media (hover: hover) {
  .tool:hover::before {
    opacity: 1;
  }
}
.tool[data-hover='true']::before {
  opacity: 1;
}
/* Open: Reply stays as the field's icon, nudged 5.5 px left; the emoji and the heart drift left
   and blur out, quicker than they come back. */
.root[data-open='true'] .tool {
  transform: translateX(-5.5px);
  transition:
    opacity 0.15s ease-in,
    filter 0.15s ease-in,
    transform var(--open-time) var(--open-spring);
}
.root[data-open='true'] .tool::before {
  opacity: 0;
}
.root[data-open='true'] .fades {
  opacity: 0;
  filter: blur(6px);
  transform: translateX(-9px);
}

/* The heart: outlined, or filled in its colour; a like pops it and a ring bursts from it. */
.heart {
  position: relative;
  display: block;
}
.tool[data-liked='true'] {
  color: var(--heart);
}
.tool[data-liked='true'] .heart path {
  fill: currentColor;
}
.heart[data-pop='true'] {
  animation: pop 0.42s cubic-bezier(0.3, 0, 0.3, 1);
}
@keyframes pop {
  0% {
    transform: scale(1);
  }
  28% {
    transform: scale(0.76);
  }
  62% {
    transform: scale(1.24);
  }
  100% {
    transform: scale(1);
  }
}
.burst {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 2px solid var(--heart);
  opacity: 0;
  pointer-events: none;
  animation: burst 0.5s cubic-bezier(0.2, 0.6, 0.3, 1) 0.1s;
}
@keyframes burst {
  0% {
    opacity: 0.7;
    transform: scale(0.4);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
    border-width: 0.5px;
  }
}

/* The field's words: from 52 px, clear of the send button. Closed, they wait 7 px to the right,
   blurred out. */
.input {
  position: absolute;
  top: 0;
  left: 52px;
  right: 88px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--ink);
  caret-color: var(--ink);
  font-family: inherit;
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
  opacity: 0;
  filter: blur(6px);
  transform: translateX(7px);
  transition:
    opacity 0.13s ease-in,
    filter 0.13s ease-in,
    transform var(--close-time) var(--close-spring);
}
.input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}
.root[data-open='true'] .input {
  opacity: 1;
  filter: blur(0);
  transform: none;
  transition:
    opacity 0.2s ease-out 0.08s,
    filter 0.24s ease-out 0.08s,
    transform var(--open-time) var(--open-spring);
}
.root[data-sent='true'] .input {
  opacity: 0.45;
}
/* A hidden copy of the words, for the demo's caret; the same type as the field. */
.mirror {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.caret {
  position: absolute;
  top: 17px;
  left: var(--x);
  width: 2px;
  height: 22px;
  border-radius: 1px;
  background: var(--ink);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* The black buttons: the plus beside the pill, the send inside its right end. */
.action,
.send {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: var(--action);
  color: var(--action-ink);
  cursor: pointer;
  box-shadow:
    inset 0 0 0 1px var(--action-edge),
    inset 0 1px 0 var(--action-edge),
    0 2px 6px var(--action-shadow);
}
.action:focus-visible,
.send:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.glyph {
  display: block;
  width: 24px;
  height: 24px;
}
/* The plus: 81 × 53 px, 37 px right of the pill. Open, it blurs away 15 px to the right as the
   send button comes into focus over where it was. */
.action {
  top: 1.5px;
  left: 215px;
  width: 81px;
  height: 53px;
  border-radius: 24px;
  transition:
    opacity 0.24s ease-out 0.1s,
    filter 0.26s ease-out 0.1s,
    transform var(--close-time) var(--close-spring);
}
.action:active .glyph,
.send:active .glyph {
  transform: scale(0.9);
}
.root[data-open='true'] .action {
  opacity: 0;
  filter: blur(8px);
  transform: translateX(15px);
  transition:
    opacity 0.2s ease-in,
    filter 0.2s ease-in,
    transform var(--open-time) var(--open-spring);
}
/* The send button: 76 × 47 px, 4.5 px inside the pill's right end, so it travels with the
   edge. Closed, it waits there unseen, blurred out. */
.send {
  top: 4.5px;
  right: 4.5px;
  width: 76px;
  height: 47px;
  border-radius: 23.5px;
  opacity: 0;
  filter: blur(8px);
  transition:
    opacity 0.18s ease-in,
    filter 0.18s ease-in;
}
.root[data-open='true'] .send {
  opacity: 1;
  filter: blur(0);
  transition:
    opacity 0.26s ease-out 0.04s,
    filter 0.28s ease-out 0.04s;
}
@media (hover: hover) {
  .action:hover,
  .send:hover {
    filter: brightness(1.12);
  }
  .root[data-open='true'] .send:hover {
    filter: brightness(1.12);
  }
}
.send[data-hover='true'] {
  filter: brightness(1.12);
}
/* Sent: the plane flies off up and to the right, and a check lands in its place. */
.send .glyph {
  grid-area: 1 / 1;
  transition:
    opacity 0.2s ease,
    transform 0.3s cubic-bezier(0.3, 0, 0.2, 1);
}
.check {
  opacity: 0;
  transform: scale(0.5);
}
.root[data-sent='true'] .plane {
  opacity: 0;
  transform: translate(14px, -14px) scale(0.8);
}
.root[data-sent='true'] .check {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.2s ease 0.12s,
    transform 0.36s cubic-bezier(0.3, 1.5, 0.5, 1) 0.12s;
}

/* The emoji picker: a small pill of six over the emoji button. */
.picker {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 6px;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 24px;
  background: linear-gradient(var(--pill-top) 30%, var(--pill-foot));
  box-shadow:
    inset 0 0 0 1px var(--pill-edge),
    0 1px 2px var(--pill-shadow),
    0 10px 24px var(--pill-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(0.94);
  transform-origin: 30% 100%;
  filter: blur(4px);
  transition:
    opacity 0.14s ease-in,
    filter 0.14s ease-in,
    transform 0.14s ease-in,
    visibility 0s linear 0.14s;
}
.picker[data-shown='true'] {
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: none;
  transition:
    opacity 0.2s ease-out,
    filter 0.2s ease-out,
    transform var(--open-time) var(--open-spring),
    visibility 0s;
}
.emoji {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: none;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.12s ease,
    transform 0.15s ease;
}
.emoji:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}
@media (hover: hover) {
  .emoji:hover {
    background: var(--chip);
    transform: scale(1.12);
  }
}
.emoji:active {
  transform: scale(0.92);
}

/* The demo pointer, over everything; one of its glyphs shows at a time. */
.pointerLayer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.pointer {
  width: 24px;
  height: 24px;
}
.hand {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .arrow {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .hand {
  visibility: visible;
}

.hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Reduced motion: the two states swap at once, without springs, blur, pop or burst. */
@media (prefers-reduced-motion: reduce) {
  .root *,
  .root *::before {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
  .root[data-open='true'] .fades,
  .root[data-open='true'] .action,
  .send,
  .input,
  .picker {
    filter: none;
  }
  .heart[data-pop='true'],
  .burst {
    animation: none;
  }
  .caret {
    animation: none;
  }
}
```

### reply-bar/icons.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The bar's glyphs, drawn on a 24-unit grid. The outlined ones (comment, emoji, heart) take the
 * ink colour by currentColor; the plus, the plane and the check are drawn in the black button's
 * ink. All are decorative: each button carries its own name.
 */

type IconProps = { className?: string };

const outline = {
  fill: 'none',
  stroke: 'currentColor',
  strokeWidth: 2.1,
  strokeLinecap: 'round',
  strokeLinejoin: 'round',
} as const;

export function CommentIcon({ className }: IconProps) {
  return (
    <svg className={className} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
      {/* A rounded bubble with its tail at the lower left, and two lines of words. */}
      <path
        d="M7 4h10a4 4 0 0 1 4 4v5a4 4 0 0 1-4 4h-5.2L7.4 20.3c-.5.4-1.2 0-1.2-.6V17A4 4 0 0 1 3 13V8a4 4 0 0 1 4-4z"
        {...outline}
      />
      <path d="M8 9.2h8M8 12.6h5" {...outline} />
    </svg>
  );
}

export function EmojiIcon({ className }: IconProps) {
  return (
    <svg className={className} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
      <circle cx="12" cy="12" r="9" {...outline} />
      <circle cx="9" cy="10" r="1.25" fill="currentColor" />
      <circle cx="15" cy="10" r="1.25" fill="currentColor" />
      <path d="M8.4 14.2c1.9 2.4 5.3 2.4 7.2 0" {...outline} />
    </svg>
  );
}

export function HeartIcon({ className }: IconProps) {
  return (
    <svg className={className} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
      <path
        d="M12 20.2s-8.2-4.9-8.2-11a4.6 4.6 0 0 1 8.2-2.9 4.6 4.6 0 0 1 8.2 2.9c0 6.1-8.2 11-8.2 11z"
        {...outline}
      />
    </svg>
  );
}

export function PlusIcon({ className }: IconProps) {
  return (
    <svg className={className} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
      <path
        d="M12 5v14M5 12h14"
        fill="none"
        stroke="currentColor"
        strokeWidth="2.6"
        strokeLinecap="round"
      />
    </svg>
  );
}

export function SendIcon({ className }: IconProps) {
  return (
    <svg className={className} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
      {/* A paper plane pointing up and right, its fold a notch cut toward the tip. */}
      <path
        d="M20.4 3.6 3.9 10.3c-.7.3-.6 1.2.1 1.4l6.6 1.8 1.8 6.6c.2.7 1.1.8 1.4.1z"
        fill="currentColor"
        stroke="currentColor"
        strokeWidth="1"
        strokeLinejoin="round"
      />
      <path
        d="m10.9 13.1 4.4-4.4"
        fill="none"
        stroke="var(--action)"
        strokeWidth="1.5"
        strokeLinecap="round"
      />
    </svg>
  );
}

export function CheckIcon({ className }: IconProps) {
  return (
    <svg className={className} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
      <path
        d="m5.5 12.5 4.2 4.2 8.8-9"
        fill="none"
        stroke="currentColor"
        strokeWidth="2.6"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}
```

### reply-bar/demo-pointer.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import type { CSSProperties, Ref } from 'react';

/*
 * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or
 * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends
 * the step in progress at once: its promise rejects, which ends the script right there, and the
 * pointer fades out.
 *
 * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame.
 * The points of the flight are handed to whoever wants to move along with it (nothing here uses
 * them yet). The arrow and the hand are HTML boxes
 * that swap by their visibility: a change of style inside an SVG would lay the SVG out again.
 */

export type Point = { x: number; y: number };

/** A glide's path and timing, for an animation that plays along with it. */
export type Flight = { points: Point[]; timing: KeyframeAnimationOptions };

export type Demo = {
  /** Resolves after `ms`. */
  wait: (ms: number) => Promise<void>;
  /** Glides the pointer to `to`, in the stage's own px, in `ms`; `along` gets the flight. */
  glide: (to: Point, ms: number, along?: (flight: Flight) => void) => Promise<void>;
  /** Shows the arrow, or the hand a link shows. */
  glyph: (name: 'arrow' | 'hand') => void;
};

/** What a stopped demo's pending step rejects with. */
class Stopped extends Error {}

/** Where the arrow's tip is, as shares of its box: the point the pointer stands on. */
const TIP: Point = { x: 0.15, y: 0.1 };

/** How many points a flight is drawn through. */
const SAMPLES = 24;

/** Plays `script` with the pointer over `stage`; returns the function that stops it. */
export function runDemo(
  stage: HTMLElement,
  pointer: HTMLElement,
  script: (demo: Demo) => Promise<void>,
): () => void {
  let alive = true;
  let flight: Animation | null = null;
  // The stylesheet sizes the pointer from the stage's width; its tip is where it stands.
  const tip = { x: pointer.offsetWidth * TIP.x, y: pointer.offsetHeight * TIP.y };
  const place = ({ x, y }: Point) => `translate(${x - tip.x}px, ${y - tip.y}px)`;
  const timers = new Set<number>();
  const pending = new Set<() => void>();
  // The pointer comes in from the lower right.
  let at: Point = { x: stage.offsetWidth * 0.8, y: stage.offsetHeight * 0.9 };

  /** Settles like `promise`, or rejects as soon as the demo stops. */
  const step = (promise: Promise<unknown>) =>
    new Promise<void>((resolve, reject) => {
      if (!alive) return reject(new Stopped());
      const cancel = () => reject(new Stopped());
      pending.add(cancel);
      promise.then(
        () => {
          pending.delete(cancel);
          if (alive) resolve();
        },
        () => {
          pending.delete(cancel);
          reject(new Stopped());
        },
      );
    });

  const wait = (ms: number) =>
    step(
      new Promise<void>((resolve) => {
        const timer = window.setTimeout(() => {
          timers.delete(timer);
          resolve();
        }, ms);
        timers.add(timer);
      }),
    );

  const glide: Demo['glide'] = (to, ms, along) => {
    const from = at;
    at = to;
    const dx = to.x - from.x;
    const dy = to.y - from.y;
    // A gentle curve, as a hand moves: the control point sits off the straight line.
    const bend = { x: (from.x + to.x) / 2 - dy * 0.18, y: (from.y + to.y) / 2 + dx * 0.18 };
    const points: Point[] = [];
    for (let i = 0; i <= SAMPLES; i += 1) {
      const t = i / SAMPLES;
      const u = 1 - t;
      points.push({
        x: u * u * from.x + 2 * u * t * bend.x + t * t * to.x,
        y: u * u * from.y + 2 * u * t * bend.y + t * t * to.y,
      });
    }
    const timing: KeyframeAnimationOptions = {
      duration: ms,
      easing: 'cubic-bezier(0.45, 0, 0.25, 1)',
    };
    flight?.cancel();
    // Where it rests once the flight is over.
    pointer.style.transform = place(to);
    flight = pointer.animate(
      points.map((point) => ({ transform: place(point) })),
      timing,
    );
    along?.({ points, timing });
    return step(flight.finished);
  };

  const glyph: Demo['glyph'] = (name) => {
    pointer.dataset.glyph = name;
  };

  pointer.dataset.glyph = 'arrow';
  pointer.style.transform = place(at);
  pointer.style.opacity = '1';
  script({ wait, glide, glyph }).catch((error: unknown) => {
    if (!(error instanceof Stopped)) throw error;
  });

  return () => {
    if (!alive) return;
    alive = false;
    timers.forEach((timer) => window.clearTimeout(timer));
    flight?.cancel();
    pending.forEach((cancel) => cancel());
    pointer.style.opacity = '0';
  };
}

/**
 * The pointer's box: it moves, on a layer of its own. Its size comes from its class, its colours
 * from the stage's tokens (reply-bar.module.css).
 */
const POINTER: CSSProperties = {
  position: 'absolute',
  top: 0,
  left: 0,
  zIndex: 2,
  display: 'block',
  pointerEvents: 'none',
  opacity: 0,
  transition: 'opacity 0.3s ease',
  filter: 'drop-shadow(0 1px 1.5px var(--pointer-shadow))',
  willChange: 'transform',
};

/** One glyph over the other, each filling the box. */
const GLYPH: CSSProperties = { position: 'absolute', inset: 0, display: 'block' };
const DRAWING: CSSProperties = {
  display: 'block',
  width: '100%',
  height: '100%',
  overflow: 'visible',
};
/** The arrow is dark on a white edge, the hand white on a dark one, as the system draws them. */
const ARROW: CSSProperties = { fill: 'var(--pointer)', stroke: 'var(--pointer-edge)' };
const HAND: CSSProperties = { fill: 'var(--pointer-edge)', stroke: 'var(--pointer)' };

/**
 * The pointer the demo moves around: an arrow, or a pointing hand over a control. It is
 * decorative: what it does shows on the control itself. The stylesheet shows one glyph at a time,
 * from the box's data-glyph.
 */
export function DemoPointer({
  ref,
  className,
  arrowClass,
  handClass,
}: {
  ref: Ref<HTMLSpanElement>;
  className?: string;
  arrowClass?: string;
  handClass?: string;
}) {
  return (
    <span ref={ref} className={className} style={POINTER} aria-hidden="true">
      <span className={arrowClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          <path
            d="M3 2v14.5l3.6-3.3 2.6 5.6 2.4-1.1-2.6-5.5h5.2z"
            style={ARROW}
            strokeWidth="1.3"
            strokeLinejoin="round"
          />
        </svg>
      </span>
      <span className={handClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          {/* The tip of the finger sits where the arrow's tip is. */}
          <path
            d="M6.4 3.3c0-.8.6-1.4 1.3-1.4S9 2.5 9 3.3v5.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.7c.2-.4.6-.7 1.1-.7.7 0 1.2.5 1.2 1.2v3.5c0 2.8-1.9 4.9-4.6 4.9h-1.2c-1.8 0-3.1-.8-4.1-2.3l-2.6-3.9c-.4-.6-.2-1.3.4-1.7.6-.3 1.3-.2 1.7.4l.6.9z"
            style={HAND}
            strokeWidth="1.1"
            strokeLinejoin="round"
            transform="translate(-4.7 0.1)"
          />
        </svg>
      </span>
    </span>
  );
}
```

### reply-bar/use-autoplay.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import { useCallback, useEffect, useRef, useState } from 'react';

/*
 * When a demo may play on its own: while part of it is on screen and the tab is visible, never
 * under reduced motion, and never again once the reader has used it: `take()` hands it to the
 * reader for good (until the component mounts again), so it can't come back on its own.
 */
export function useAutoplay<T extends HTMLElement>() {
  const ref = useRef<T>(null);
  const [visible, setVisible] = useState(false);
  const [reduced, setReduced] = useState(true);
  const [taken, setTaken] = useState(false);

  useEffect(() => {
    const element = ref.current;
    if (!element) return;
    let onScreen = false;
    const update = () => setVisible(onScreen && !document.hidden);
    const observer = new IntersectionObserver(
      ([entry]) => {
        onScreen = entry.isIntersecting;
        update();
      },
      { threshold: 0.3 },
    );
    observer.observe(element);
    document.addEventListener('visibilitychange', update);
    const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
    const readMotion = () => setReduced(motion.matches);
    readMotion();
    motion.addEventListener('change', readMotion);
    return () => {
      observer.disconnect();
      document.removeEventListener('visibilitychange', update);
      motion.removeEventListener('change', readMotion);
    };
  }, []);

  const take = useCallback(() => setTaken(true), []);

  return { ref, take, playing: visible && !reduced && !taken };
}
```