chat-bubble-left-right
An animated chat-bubble-left-right icon for React, rendered as an outlined SVG speech-bubble pair that wobbles and scales on hover. It can also be driven imperatively through a ref with startAnimation and stopAnimation.
shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { ChatBubbleLeftRightIcon } from "@/components/ui/chat-bubble-left-right";export function Example() { return <ChatBubbleLeftRightIcon className="text-blue-500" size={32} />;}- Chat, messaging, comment, or support entry points where a speech-bubble icon should react to hover
- Navigation items or buttons that need a subtle, playful micro-interaction on mouse hover
- Interfaces where a parent component must trigger the icon animation programmatically via a ref (for example when a new message arrives)
- Toolbars or menus that need a lightweight animated icon without building custom motion code
Examples
Basic hover icon
Renders the icon with default size (28) and animates on mouse enter and leave.
import { ChatBubbleLeftRightIcon } from "@/components/ui/chat-bubble-left-right";export function BasicExample() { return <ChatBubbleLeftRightIcon />;}Imperative control via ref
Passing a ref switches the component to controlled mode, so hover no longer animates it automatically and the parent calls startAnimation and stopAnimation.
import { useRef } from "react";import { ChatBubbleLeftRightIcon, type ChatBubbleLeftRightIconHandle } from "@/components/ui/chat-bubble-left-right";export function ControlledExample() { const iconRef = useRef<ChatBubbleLeftRightIconHandle>(null); return ( <div onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()}> <ChatBubbleLeftRightIcon ref={iconRef} size={24} /> </div> );}Icon inside a button
Uses the icon as a decorative leading icon next to a text label with a custom size and color.
import { ChatBubbleLeftRightIcon } from "@/components/ui/chat-bubble-left-right";export function ChatButton() { return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm"> <ChatBubbleLeftRightIcon size={18} className="text-violet-600" aria-hidden="true" /> Start chat </button> );}Notification trigger
Plays the animation once when a new message count changes, using the imperative handle.
import { useEffect, useRef } from "react";import { ChatBubbleLeftRightIcon, type ChatBubbleLeftRightIconHandle } from "@/components/ui/chat-bubble-left-right";export function UnreadIndicator({ unread }: { unread: number }) { const iconRef = useRef<ChatBubbleLeftRightIconHandle>(null); useEffect(() => { if (unread > 0) { iconRef.current?.startAnimation(); const id = window.setTimeout(() => iconRef.current?.stopAnimation(), 1000); return () => window.clearTimeout(id); } }, [unread]); return <ChatBubbleLeftRightIcon ref={iconRef} size={22} />;}API reference
Accessibility
- The component renders an SVG with no title, desc, or role, so it is decorative by default; add aria-hidden="true" when a text label is present nearby.
- When the icon is the only content of an interactive control, provide an accessible name on the parent button or link (for example aria-label="Open chat") because the SVG itself carries no label.
- Hover animation is purely visual and is not announced to assistive technology; do not rely on it to convey state or information.
- Respect reduced-motion preferences by disabling or shortening the animation in the parent (for example by not calling startAnimation when prefers-reduced-motion is set), since the component does not check that media query itself.
- The wrapper is a div with mouse handlers only; it is not focusable, so keyboard users cannot trigger the hover animation. Keyboard-triggered effects must be wired through the ref handle from a focusable parent.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "chat-bubble-left-right" component (heroicons-animated/chat-bubble-left-right) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/chat-bubble-left-right2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, className, onMouseEnter, onMouseLeave, ref, ...props (HTMLAttributes<HTMLDivElement>).Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { ChatBubbleLeftRightIcon } from "@/components/ui/chat-bubble-left-right";export function Example() { return <ChatBubbleLeftRightIcon className="text-blue-500" size={32} />;}```Files & dependencies
- chat-bubble-left-right.tsx