Composer that opens when you need it
28 November 2026
A message composer that stays one line until you click in, then shows its buttons and grows with what you type.
One line at rest
Most of the time nobody is typing. A composer that is always fully open, with suggestions, a toolbar and an empty two-line box, takes space from the screen for nothing.
At rest this one is a single line: a quiet plus, the placeholder, and the mic. Click into it.
Open on focus
When you click in, the suggestions slide in above and the box splits into two rows: your text on top, the plus and send below. Click away with nothing typed and it folds back to one line. A draft keeps it open.
field.addEventListener("focus", () => setExpanded(true));
dock.addEventListener("focusout", (e) => {
if (!dock.contains(e.relatedTarget) && !field.value.trim()) setExpanded(false);
});.chips-wrap { display: grid; grid-template-rows: 0fr; opacity: 0;
transition: grid-template-rows 200ms, opacity 200ms; }
.open .chips-wrap { grid-template-rows: 1fr; opacity: 1; }
.chips-inner { min-height: 0; overflow: hidden; }Make the jump a glide
Going from one row to two is a layout change, so on its own it snaps. Measure the box, switch, measure again, and tween the height between the two.
Lay the rows out from the bottom and the buttons never move: send stays bottom right, the plus stays bottom left. Only the text rides up with the top edge, sliding past the plus.
function setExpanded(on) {
const h0 = pill.offsetHeight, x0 = field.getBoundingClientRect().left;
dock.classList.toggle("open", on);
const h1 = pill.offsetHeight, x1 = field.getBoundingClientRect().left;
const glide = { duration: 380, easing: "cubic-bezier(.32, .72, 0, 1)" };
pill.animate([{ height: `${h0}px` }, { height: `${h1}px` }], glide);
field.animate([{ transform: `translateX(${x0 - x1}px)` }, { transform: "none" }], glide);
}.pill { display: flex; flex-wrap: wrap; align-items: flex-end;
align-content: flex-end; justify-content: flex-end; overflow: hidden; }
.plus { margin-right: auto; }
.open .field { order: -1; width: 100%; }Grow with the text
The field grows line by line up to six lines, then scrolls. The usual trick sets height: auto and reads scrollHeight, but that cancels a height transition mid-flight, so every new line snaps.
Measure on a hidden copy instead, and the real field keeps easing.
function target() {
mirror.style.width = `${field.offsetWidth}px`;
mirror.value = field.value || field.placeholder;
return Math.min(mirror.scrollHeight, 128);
}
field.addEventListener("input", () => {
field.style.height = `${target()}px`; // transition: height 150ms ease-out
});Send and settle
Send clears the field in the same frame, so it eases back to one line while focus stays put. The mic comes back when the field is empty, and under prefers-reduced-motion the box still resizes, just without the easing.