Chat Container
shadcn-collections/chat-containerFreeComponent
Chat container component for messaging interfaces
Install it
npx shadcn@latest add https://chatcn.me/r/chat-container.jsonSource
1"use client";2import { cn } from "@/lib/utils";3import { useEffect, useRef } from "react";45export default function ChatContainer({6 children,7 className,8}: {9 children: React.ReactNode;10 className?: string;11}) {12 const chatRef = useRef<HTMLDivElement>(null);1314 useEffect(() => {15 if (!chatRef.current) return;1617 const observer = new MutationObserver(() => {18 if (chatRef.current) {19 chatRef.current.scrollTo({20 top: chatRef.current.scrollHeight,21 behavior: "smooth",22 });23 }24 });2526 observer.observe(chatRef.current, { childList: true, subtree: true });27 return () => observer.disconnect();28 }, []);2930 return (31 <div className={cn("flex flex-col", className)}>32 <div33 ref={chatRef}34 className="space-y-5 flex-1 overflow-auto px-10 py-4 rounded"35 >36 {children}37 </div>38 </div>39 );40}
Files it writes
More from shadcn-collections
All 24 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Audio Visualizeraudio-visualizer | shadcn-collections | Components | Free | 4 deps | |
| Calendarcalendar | shadcn-collections | Components | Free | no deps | |
| Code Editorcode-editor | shadcn-collections | Components | Free | no deps | |
| Code Blockcodeblock | shadcn-collections | Components | Free | 1 dep | |
| Command Blockcommand-block | shadcn-collections | Components | Free | no deps | |
| Command Tabscommand-tabs | shadcn-collections | Components | Free | no deps | |
| Emailemail | shadcn-collections | Components | Free | no deps | |
| Filefile | shadcn-collections | Components | Free | no deps |
