Reply bar
NewA pill of post actions and a black plus that merge into one reply field, the plus turning into its send button.
The live component, numbered part by part. Every measurement is read from it as it is drawn. Point at a row to outline its part, or at a part to find its row.
The choices it offers, each value drawn live and the default marked, with how to pick one.
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.
Each one drawn with the component itself, used well or badly.
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.
You can add this component with the shadcn CLI or by hand:
Into components/reply-bar of any React project, with no setup:
npx shadcn@latest add https://brunodelorence.com/r/reply-bar.json- Copy the component files
Copy these files into one folder of your project, keeping their relative imports together, or download them as a ZIP:
- Import it
As shown under Usage, below.
Either way it needs React 19.2 and a bundler that supports CSS Modules, such as Next.js or Vite. It has a dark colour scheme: 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
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)} /> );}Each state below is a live instance, locked so you can study it.
The pieces it is built from, each with its measurements read live.
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.
- 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.
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | string | 'Write a reply' | The field’s placeholder; keep it to about 156 px of text. |
defaultValue | string | '' | A draft already in the field. |
defaultLiked | boolean | false | Starts with the heart filled. |
defaultOpen | boolean | 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 | 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. |
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-expandedandaria-controlson the field; Like is a toggle witharia-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.
The complete source behind this demo. Open source under the MIT license, © 2026 Bruno Delorence: copy it, change it, ship it.
// 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./* 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;// 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"// 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 = {// 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]) => {