- Home
- Code Library
- React Chat Application Tutorial
React Chat Application Tutorial
4.0
en
Programming
React
Chat Application
Frontend Development
Prompt
import React, { useState } from 'react'; const App = () => { const [messages, setMessages] = useState([]); const [inputText, setInputText] = useState(''); const [userName, setUserName] = useState(''); const [userColor, setUserColor] = useState('#000000'); const handleSendMessage = () => { if (inputText.trim()) { const newMessage = { id: messages.length + 1, text: inputText, userName, userColor, timestamp: new Date().toLocaleTimeString(), }; setMessages([...messages, newMessage]); setInputText(''); } }; return ( <div className="min-h-screen bg-gray-100 p-6"> <div className="max-w-4xl mx-auto bg-white rounded-lg shadow-lg overflow-hidden"> <div className="p-6 border-b border-gray-200"> <h1 className="text-2xl font-bold text-gray-800">ChatGPT</h1> </div> <div className="p-6 space-y-4"> {messages.map((message) => ( <div key={message.id} className="flex space-x-4"> <div className="w-10 h-10 rounded-full flex items-center justify-center text-white" style={{ backgroundColor: message.userColor }} > {message.userName.charAt(0)} </div> <div className="flex-1"> <p className="text-sm text-gray-600 font-semibold">{message.userName}</p> <p className="text-gray-800">{message.text}</p> <p className="text-xs text-gray-500">{message.timestamp}</p> </div> </div> ))} </div> <div className="p-6 border-t border-gray-200"> <div className="flex space-x-4"> <input type="text" value={userName} onChange={(e) => setUserName(e.target.value)} placeholder="Your Name" className="flex-1 p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" /> <input type="color" value={userColor} onChange={(e) => setUserColor(e.target.value)} className="w-12 h-12 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" /> </div> <div className="mt-4 flex space-x-4"> <input type="text" value={inputText} onChange={(e) => setInputText(e.target.value)} placeholder="Type a message..." className="flex-1 p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" /> <button onClick={handleSendMessage} className="px-6 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500" > Send </button> </div> </div> </div> </div> ); }; export default App; بعد ما تكتب الاسم بحولك الى القائمة الاصدقاء والمجموعاة
Generated Result
More Recommendations
View All30天投资赚$90
4.0
金融投资
en
投资
staking
赚钱
$10Investment in 30 days staking $90 earning per day $3 earn insten $3 withdrawal app ...
30天投资$10日赚$3
4.0
金融
en
投资
赚钱
质押
$10Investment in 30 days staking $90 earning per day $3 earn app ...
背景去除应用概念
4.0
技术应用
en
背景去除
AI图像处理
图像编辑工具
# Background Removal App Concept
## Overview
A simple, user-friendly application that allows users to remove backgrounds from images with high accuracy and minimal effort.
## Core Features
1. **Dra...
One-Click Background Removal
4.0
Technology
en
background removal
image editing
application
Create an application to remove the background with one click and it must be strange Bolt give me Bromwich management on his behalf remove the button for the image with the back after I upload the ima...
照片排名系统
4.0
技术
en
照片排名
用户选择
元数据
a photo ranking system using pairwise choices, where user chooses from 2 side ny side images, photos have associasted metadata and multiple users...
Water Delivery App
4.0
Technology
en
water delivery
delivery app
GPS tracking
Water delivery app
Customer contact number address location
Delivery boy contact number GPS live location
...