Animated Chat Bubble
ChatBubble is the root and publishes variant and layout through context, so ChatAvatar, ChatMessage and ChatTimestamp style themselves without being told twice.Conversation
The pieces assembled into a messenger thread — set the side once on the ChatBubble root and the children read it from context.
- Set
variant"sent" - on the root to align the row right — it also unlocks
coloronChatMessageand the ticks onChatTimestamp. variant"received"- is the default: aligns left and forces the neutral zinc bubble whatever
colorsays. color"blue"- on
ChatMessagepicks the sent-bubble fill —primary,default,blue,indigo,roseoremerald, not an arbitrary hex. status"read"- on
ChatTimestampadds the blue double tick after the time. fallback"SJ"- on
ChatAvataris required — the initials show untilsrcloads, and stay if it fails.
Installation
New project? Follow the installation guide to set up Tailwind CSS, shadcn, the cn helper and lucide-react, register the @algorize-ui registry once, then copy your styles from the Themes page.
Install Chat Bubble
components/ is written into your project. Copy any snippet from a Usage tab above and it runs.
Install dependencies
Nothing beyond the shared setup — Chat Bubble needs only the cn helper and lucide-react, which the installation guide already put in place.
Examples
Message grouping
layout"default"- is the default — a fully rounded 16px bubble with a visible avatar, for a standalone message.
- Use
layout"group-top" - on the first bubble of a run: the bottom inner corner tightens to 4px and the avatar is hidden.
layout"group-middle"- tightens both inner corners and hides the avatar.
layout"group-bottom"- closes the run — tightens the top inner corner and brings the avatar back. The corners mirror automatically for
sentbubbles.
Timestamps & read receipts
- Pass
time"10:25 AM" - as a plain string — required, and formatted by you, so
Just nowworks in the same slot. status"sent"- renders one grey tick.
status"delivered"- renders two grey ticks.
status"read"- renders two blue ticks.
status- left off shows the time alone — which is also what a
receivedbubble does whatever you pass.
Typing indicator
ChatTypingIndicator takes no props of its own — it draws its own pill and loops until you unmount it.
variant"received"- on the root gives the dots a zinc pill, cornered to the left.
variant"sent"- inverts it — dark pill, light dots, cornered to the right.
Features
Fluid Animations
Hardware-accelerated transitions that ensure smooth 60fps performance across devices.
Highly Customizable
Exposes intuitive props for tailoring colors, sizes, and animation speeds to fit your brand.
Responsive Design
Automatically adapts to mobile, tablet, and desktop viewports without horizontal scrolling issues.
Accessible
Built with semantic HTML and ARIA labels where necessary to support screen readers and keyboard navigation.
Best Practices & Guidelines
Animation Performance
Avoid placing too many heavy animated components on a single screen to prevent layout thrashing and maintain 60fps performance. Use intersection observers to pause off-screen animations.
State Management
When triggering animations via state changes, ensure you wrap state updates in startTransition or use lightweight stores to prevent React rendering bottlenecks during the animation tick.
Props Reference
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
ChatBubble | variant | "sent" | "received" | "received" | Dictates the alignment of the message. "sent" aligns
right, "received" aligns left. |
ChatBubble | layout | "default" | "group-top" | "group-middle" | "group-bottom" | "default" | Controls the dynamic border-radius logic to seamlessly connect stacked
messages from the same sender. |
ChatAvatar | src | string | undefined | Optional image URL for the user's avatar. |
ChatAvatar | fallback | string | Required | The text initials to display if the image is missing or fails to load. |
ChatMessage | color | "primary" | "default" | "blue" | "indigo" | "rose" | "emerald" | "primary" | Sets the background color of the bubble. Only applies when the parent
variant is set to "sent".
"primary" and "default" both follow your
theme tokens, and any unlisted value falls back to them — this is a
fixed set, not an arbitrary hex. |
ChatTimestamp | time | string | Required | The timestamp string rendered below the text (e.g., "10:24 AM"). |
ChatTimestamp | status | "sent" | "delivered" | "read" | undefined | Renders Lucide checkmarks to indicate read receipts. Only visible if
the parent variant is "sent". |
All Components | className | string | undefined | Accepts custom Tailwind CSS classes to override default styling. All
components also accept standard HTML <div>
attributes. |