Send morph
Sending as a motion: the words leave the composer and travel into the bubble they become, which grows its fill and corners around them.
On this page
Send a message: the words leave the composer and travel into the bubble they become, which grows its fill and corners around them.
A sent message usually blinks out of the composer and appears in the thread. Here the words travel: they lift from where they were typed and settle into the bubble, laid out at the bubble's width from the first frame so lines never rewrap in flight, while the box around them grows from a hairline into the bubble's own fill and corners. The composer's text clears as the words leave.
Installation
Usage
import { sendMorph } from "@/components/ui/chatcn/send-morph"
async function send(text: string) {
const id = addUserMessage(text) // render the bubble first
clearComposer()
await nextFrame()
await sendMorph({ from: textarea, to: bubbleFor(id), text })
}Render the bubble, then call sendMorph; the bubble stays hidden until the words land. Hide the composer's placeholder for the first 300 ms so it never shows through the departing text.
Props
| Prop | Type | Notes |
|---|---|---|
from | HTMLElement | The composer's text field |
to | HTMLElement | The sent bubble, already rendered |
text | string | The message |
duration | number | Milliseconds. Default 420 |
Accessibility
- The travelling copy is
aria-hidden; the real bubble is what assistive tech reads. - Under reduced motion the bubble simply appears.
Motion
- One Web Animations run on
transform,clip-path, color and background: 420 ms, ease out. - The fill arrives a third of the way in, so the words leave as text and arrive as a bubble.