NOCTA UI

Chat

A comprehensive chat component system with message display, input handling, avatars, timestamps, and real-time messaging capabilities

Installation

Install the Chat component using the nocta-ui CLI:

npx @nocta-ui/cli add chat

Then import the components you need:

import {
  Chat,
  ChatMessages,
  ChatMessage,
  ChatInput,
  ChatActions,
  TypingIndicator,
  type ChatMessage,
  type TypingUser,
} from '@/components/ui/chat';

Examples

Default Chat

Hello! How can I help you today?
0/500

Chat with Avatars

Alice
Hey everyone! Welcome to the group chat 👋
09:03 PM
Bob
Thanks for setting this up! Looking forward to our collaboration.
09:05 PM
Alice joined the chat
09:13 PM
Charlie
Same here! This is going to be great.
09:30 PM
0/500

Chat with Timestamps

Good morning! How can I assist you today?
09:58 PM
Hi! I have a question about my account.
09:59 PM
Of course! I'd be happy to help with your account. What specific question do you have?
10:00 PM
I'm trying to update my billing information but can't find the option.
10:01 PM
I can guide you through that! Go to Settings > Account > Billing Information.
10:02 PM
0/500

Read-Only Chat

This is a read-only chat
10:02 PM
A
Perfect for displaying conversation history
10:03 PM
U
Or showing announcements and updates
10:03 PM

Typing Indicators

Typing Indicator Demo

Sarah
Hey there! Welcome to the team chat 👋
09:58 PM
Y
Thanks! Excited to be here and start collaborating.
09:59 PM
0/500

Features demonstrated:

  • Single user typing indicator
  • Multiple users typing simultaneously
  • Smart text that handles different user counts
  • Animated bouncing dots
  • Integration with avatars

API Reference

Message Interface

interface ChatMessage {
  id: string;                    // Unique message identifier
  content: string;               // Message text content
  sender: 'user' | 'assistant' | 'system'; // Message sender type
  timestamp: Date;               // Message timestamp
  avatar?: string;               // Optional avatar URL
  name?: string;                 // Optional sender name
}

TypingUser Interface

interface TypingUser {
  id: string;                    // Unique user identifier
  name?: string;                 // Optional user name
  avatar?: string;               // Optional avatar URL
}

Prop

Type