Avara UI

Animated Chat Bubble

A complete, CSS-animated compound component system for building highly customized chat interfaces, messengers, and support widgets.
Building a polished chat interface requires handling complex edge cases: message grouping (dynamically adjusting border radiuses so stacked messages look connected), typing indicators, read receipts, and smooth entrance animations. This component abstracts all of that logic using React Context and lightweight CSS animations — no animation library.

These are compound components: 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.

Setvariant"sent"
on the root to align the row right — it also unlocks color on ChatMessage and the ticks on ChatTimestamp.
variant"received"
is the default: aligns left and forces the neutral zinc bubble whatever color says.
color"blue"
on ChatMessage picks the sent-bubble fill — primary, default, blue, indigo, rose or emerald, not an arbitrary hex.
status"read"
on ChatTimestamp adds the blue double tick after the time.
fallback"SJ"
on ChatAvatar is required — the initials show until src loads, 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

npx shadcn@latest add @algorize-ui/chat-bubble

components/custom/blocks/ChatBubbleBlock.tsx 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.
Uselayout"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 sent bubbles.

Timestamps & read receipts

Passtime"10:25 AM"
as a plain string — required, and formatted by you, so Just now works 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 received bubble 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

Discover the key capabilities that make this component an excellent choice for modern, animated user interfaces.

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

ComponentPropTypeDefaultDescription
ChatBubblevariant"sent" | "received""received"
Dictates the alignment of the message. "sent" aligns right, "received" aligns left.
ChatBubblelayout"default" | "group-top" | "group-middle" | "group-bottom""default"
Controls the dynamic border-radius logic to seamlessly connect stacked messages from the same sender.
ChatAvatarsrcstringundefinedOptional image URL for the user's avatar.
ChatAvatarfallbackstringRequired
The text initials to display if the image is missing or fails to load.
ChatMessagecolor"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.
ChatTimestamptimestringRequired
The timestamp string rendered below the text (e.g., "10:24 AM").
ChatTimestampstatus"sent" | "delivered" | "read"undefined
Renders Lucide checkmarks to indicate read receipts. Only visible if the parent variant is "sent".
All ComponentsclassNamestringundefined
Accepts custom Tailwind CSS classes to override default styling. All components also accept standard HTML <div> attributes.