Chat App
tripled/chat-app-shadcnuiFreeComponent
Fully functional chat interface with animated messages
Install it
npx shadcn@latest add https://ui.tripled.work/r/chat-app-shadcnui.jsonSource
1"use client";23import { Button } from "@/components/ui/button";4import { Card } from "@/components/ui/card";5import { Input } from "@/components/ui/input";6import { ScrollArea } from "@/components/ui/scroll-area";7import { AnimatePresence, motion } from "framer-motion";8import { Bot, Loader2, Send, User } from "lucide-react";9import { useEffect, useRef, useState } from "react";1011type Message = {12 id: number;13 text: string;14 sender: "user" | "bot";15 timestamp: Date;16};1718const initialMessages: Message[] = [19 {20 id: 1,21 text: "Hello! How can I help you today?",22 sender: "bot",23 timestamp: new Date(Date.now() - 60000),24 },25 {26 id: 2,27 text: "Hi there! I was wondering about your features.",28 sender: "user",29 timestamp: new Date(Date.now() - 30000),30 },31 {32 id: 3,33 text: "Of course! What would you like to know?",34 sender: "bot",35 timestamp: new Date(Date.now() - 15000),36 },37];3839export function ChatApp() {40 const [messages, setMessages] = useState<Message[]>(initialMessages);41 const [inputValue, setInputValue] = useState("");42 const [isTyping, setIsTyping] = useState(false);43 const scrollAreaRef = useRef<HTMLDivElement>(null);44 const inputRef = useRef<HTMLInputElement>(null);4546 useEffect(() => {47 // Auto-scroll to bottom when new messages arrive48 if (scrollAreaRef.current) {49 const scrollContainer = scrollAreaRef.current.querySelector(50 "[data-radix-scroll-area-viewport]"51 );52 if (scrollContainer) {53 scrollContainer.scrollTop = scrollContainer.scrollHeight;54 }55 }56 }, [messages, isTyping]);5758 const formatTime = (date: Date): string => {59 const hours = date.getHours();60 const minutes = date.getMinutes();61 const ampm = hours >= 12 ? "PM" : "AM";62 const displayHours = hours % 12 || 12;63 const displayMinutes = minutes.toString().padStart(2, "0");64 return `${displayHours}:${displayMinutes} ${ampm}`;65 };6667 const handleSend = () => {68 const trimmed = inputValue.trim();69 if (!trimmed) return;7071 const userMessage: Message = {72 id: Date.now(),73 text: trimmed,74 sender: "user",75 timestamp: new Date(),76 };7778 setMessages((prev) => [...prev, userMessage]);79 setInputValue("");80 setIsTyping(true);8182 // Simulate bot response with typing indicator83 setTimeout(() => {84 const botMessage: Message = {85 id: Date.now() + 1,86// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from tripled
All 282 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AI Chat Interfaceai-chat-interface-shadcnui | tripled | Components | Free | 2 deps | |
| AI Glow Inputai-glow-input-shadcnui | tripled | Components | Free | 2 deps | |
| AI Loading Skeletonai-loading-skeleton-shadcnui | tripled | Components | Free | 2 deps | |
| AI Response Typing Streamai-response-typing-shadcnui | tripled | Components | Free | 2 deps | |
| AI Unlock Animationai-unlock-animation-shadcnui | tripled | Components | Free | 2 deps | |
| Animated Accordionanimated-accordion-shadcnui | tripled | Components | Free | 2 deps | |
| Animated Card Stackanimated-card-stack-baseui | tripled | Components | Free | 2 deps | |
| Animated Card Stackanimated-card-stack-shadcnui | tripled | Components | Free | 2 deps |
