Message Square X
An animated message-square icon with an X inside a speech bubble. Hovering draws the X's two strokes in sequence, and a ref handle lets you trigger the animation programmatically.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { MessageSquareXIcon } from "@/components/ui/message-square-x";export default function Example() { return <MessageSquareXIcon />;}- Showing a dismiss, close, or clear-message action in chat, comment, or notification UIs where a bubble with an X conveys closing a conversation
- Adding a subtle micro-interaction to a toolbar or menu button that signals rejecting or muting a message thread
- Triggering the draw-in X animation from code, for example when a message is dismissed or an error state appears, using the exported ref handle
- Decorating empty or blocked-state panels in messaging features with an animated icon that stays lightweight because it uses motion only on two paths
Examples
Hover-triggered animation
Default usage. The X animates on mouse enter and resets on mouse leave, with no ref needed.
import { MessageSquareXIcon } from "@/components/ui/message-square-x";export default function HoverExample() { return ( <div className="flex items-center gap-2 text-zinc-800"> <MessageSquareXIcon size={32} /> <span>Dismiss conversation</span> </div> );}Programmatic control through the ref handle
Passing a ref switches the icon to controlled mode, so hover no longer triggers the animation. Call startAnimation and stopAnimation from your own logic.
import { useRef } from "react";import { MessageSquareXIcon, type MessageSquareXIconHandle,} from "@/components/ui/message-square-x";export default function ControlledExample() { const iconRef = useRef<MessageSquareXIconHandle>(null); return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2" onClick={() => { iconRef.current?.startAnimation(); setTimeout(() => iconRef.current?.stopAnimation(), 1200); }} > <MessageSquareXIcon ref={iconRef} size={20} /> Clear messages </button> );}Icon button in a chat header with custom styling
Uses className and standard div props, which are forwarded to the wrapping div, to style the icon inside a clickable header action.
import { MessageSquareXIcon } from "@/components/ui/message-square-x";export default function ChatHeaderAction({ onClose }: { onClose: () => void }) { return ( <div role="button" tabIndex={0} aria-label="Close chat" onClick={onClose} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") onClose(); }} className="cursor-pointer rounded-full p-2 text-rose-600 hover:bg-rose-50" > <MessageSquareXIcon size={24} /> </div> );}API reference
Accessibility
- The SVG has no title or aria-label, so it is decorative by default. If the icon conveys meaning on its own, add aria-label or role="img" to the wrapping div, or place visible text next to it.
- When the icon acts as a button, wrap it in a native button or give the wrapper role="button", tabIndex={0}, an aria-label, and Enter/Space key handling.
- The animation is a short one-time stroke draw (under 1 second total) and does not loop, so it is generally safe for users with reduced-motion preferences. For strict compliance, skip calling startAnimation when prefers-reduced-motion is set.
- Stroke color comes from currentColor, so the icon keeps the text color contrast of its container. Verify contrast against the background when you change the color.
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 "Message Square X" component (lucide-animated/message-square-x) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/message-square-x.json2. 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.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { MessageSquareXIcon } from "@/components/ui/message-square-x";export default function Example() { return <MessageSquareXIcon />;}```Files & dependencies
- message-square-x.tsx