Skip to content
Sign upGet access
MicrointeractionsSend morphMenu

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.

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

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/send-morph.json

Usage

tsx
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

PropTypeNotes
fromHTMLElementThe composer's text field
toHTMLElementThe sent bubble, already rendered
textstringThe message
durationnumberMilliseconds. 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.