How do I animate height with motion?
Message Bubble
User/assistant chat bubbles with avatar slot, streaming dots and copyable code blocks.
Assistant
You Assistant Animate to
autowith a spring. motion measures the target height for you:tsx<motion.div animate={{ height: open ? "auto" : 0 }} transition={{ type: "spring", stiffness: 400, damping: 30 }}/>
import { Avatar } from "@/components/ui/avatar";import { Code } from "@/components/ui/code";import { MessageBubble } from "@/components/ui/message-bubble";export function Reply({ code }: { code: string }) { return ( <MessageBubble from="assistant" avatar={<Avatar size="sm" alt="Assistant" />} streaming > <p>Here is the component:</p> <Code code={code} language="tsx" /> </MessageBubble> );}<MessageBubble>
Chat bubble. Children are rich content: <p>, inline <code>, lists, <Code>.
from*"user" | "assistant"Side and surface: "user" on the right in the accent, "assistant" on the left.
avatarReactNodeAvatar slot, e.g.
<Avatar size="sm" />.childrenReactNodeMessage content: text, code, attachments.
namestringSender shown above the bubble.
streamingbooleanShows animated typing dots after the content.
timestringTime shown next to the name, e.g. "12:04".
| Prop | Type | Default |
|---|---|---|
from*Side and surface: "user" on the right in the accent, "assistant" on the left. | "user" | "assistant" | — |
avatarAvatar slot, e.g. | ReactNode | — |
childrenMessage content: text, code, attachments. | ReactNode | — |
nameSender shown above the bubble. | string | — |
streamingShows animated typing dots after the content. | boolean | — |
timeTime shown next to the name, e.g. "12:04". | string | — |
* required. Every component also takes className.