Here's an example of a beautiful and modern chat UI using HTML and CSS:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Beautiful Chat UI</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.chat-container {
width: 90%;
max-width: 1000px;
height: 80vh;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
display: flex;
overflow: hidden;
}
.sidebar {
width: 300px;
background: #fff;
border-right: 1px solid #eee;
padding: 20px;
}
.chat-main {
flex: 1;
display: flex;
flex-direction: column;
}
.search-container {
padding: 10px;
border-bottom: 1px solid #eee;
}
.search-input {
width: 100%;
padding: 10px 15px;
border: none;
border-radius: 20px;
background: #f5f5f5;
font-size: 14px;
}
.chat-list {
overflow-y: auto;
margin-top: 20px;
}
.chat-item {
display: flex;
align-items: center;
padding: 15px 10px;
cursor: pointer;
transition: all 0.3s ease;
border-radius: 10px;
}
.chat-item:hover {
background: #f5f5f5;
}
.avatar {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 15px;
background: #9599E2;
display: flex;
align-items: center;
justify-content: center;
color: white;
}
.chat-info {
flex: 1;
}
.chat-name {
font-weight: 600;
margin-bottom: 5px;
}
.chat-preview {
font-size: 13px;
color: #666;
}
.chat-header {
padding: 20px;
border-bottom: 1px solid #eee;
display: flex;
align-items: center;
}
.chat-messages {
flex: 1;
padding: 20px;
overflow-y: auto;
background: #fafafa;
}
.message {
margin-bottom: 20px;
display: flex;
align-items: flex-start;
}
.message.received {
flex-direction: row;
}
.message.sent {
flex-direction: row-reverse;
}
.message-content {
max-width: 60%;
padding: 15px;
border-radius: 15px;
margin: 0 10px;
}
.received .message-content {
background: white;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}
.sent .message-content {
background: #9599E2;
color: white;
}
.chat-input {
padding: 20px;
border-top: 1px solid #eee;
display: flex;
align-items: center;
}
.message-input {
flex: 1;
padding: 15px;
border: none;
border-radius: 25px;
background: #f5f5f5;
margin-right: 10px;
font-size: 14px;
}
.send-button {
padding: 15px 30px;
border: none;
border-radius: 25px;
background: #9599E2;
color: white;
cursor: pointer;
transition: all 0.3s ease;
}
.send-button:hover {
background: #8BC6EC;
}
</style>
</head>
<body>
<div class="chat-container">
<div class="sidebar">
<div class="search-container">
<input type="text" class="search-input" placeholder="Search chats...">
</div>
<div class="chat-list">
<div class="chat-item">
<div class="avatar">JD</div>
<div class="chat-info">
<div class="chat-name">John Doe</div>
<div class="chat-preview">Hey, how are you?</div>
</div>
</div>
<!-- Add more chat items here -->
</div>
</div>
<div class="chat-main">
<div class="chat-header">
<div class="avatar">JD</div>
<div class="chat-info">
<div class="chat-name">John Doe</div>
</div>
</div>
<div class="chat-messages">
<div class="message received">
<div class="avatar">JD</div>
<div class="message-content">
Hey, how are you?
</div>
</div>
<div class="message sent">
<div class="avatar">ME</div>
<div class="message-content">
I'm good, thanks! How about you?
</div>
</div>
<!-- Add more messages here -->
</div>
<div class="chat-input">
<input type="text" class="message-input" placeholder="Type your message...">
<button class="send-button">Send</button>
</div>
</div>
</div>
</body>
</html>
This chat UI features:
- A clean and modern design
- Responsive layout
- Beautiful gradient background
- Sidebar with chat list
- Search functionality
- Message bubbles with different styles for sent and received messages
- Avatars for users
- Smooth animations and transitions
- Input area with send button
- Subtle shadows and depth effects
To make it even better, you could:
- Add emoji support
- Implement file attachment functionality
- Add typing indicators
- Include read receipts
- Add message timestamps
- Implement real-time functionality using WebSocket
- Add more interactive elements
- Include user status indicators
- Add message reactions
- Implement message threading
You can customize the colors, spacing, and other visual elements by modifying the CSS variables and properties to match your desired design system.