Skip to main content

Chat Message

Display chat messages from users, AI assistants, or system notifications. Perfect for building chat interfaces with full RTL support and customizable actions.

Preview

2:29 PM

What's the capital of France?

2:30 PM

The capital of France is Paris. It's known as the City of Light and is famous for its art, culture, cuisine, and iconic landmarks like the Eiffel Tower.

Installation

Terminalbash

Usage

Reacttsx

Examples

Message Roles

2:29 PM

What's the weather like today?

2:30 PM

I don't have access to real-time weather data, but I can help you find weather information!

2:25 PM

Chat session started. Messages are end-to-end encrypted.

tsx

With Actions

2:31 PM

Here's the code you requested. Feel free to copy it or ask me to regenerate a different version.

tsx

Compact Variant

Quick question

Quick response

tsx

Props

NameTypeDefaultDescription
role
Required
'user' | 'assistant' | 'system'The role/sender of the message
content
Required
stringThe message content (supports markdown)
variant
'default' | 'compact''default'Visual style variant
state
'complete' | 'streaming' | 'error''complete'Message state for animations and styling
timestamp
stringOptional timestamp to display
avatar
stringOptional avatar URL
name
stringOptional name/label for the sender
showCopy
booleantrueShow copy button
showRegenerate
booleanfalseShow regenerate button (assistant only)
onCopy
() => voidCallback when copy is clicked
onRegenerate
() => voidCallback when regenerate is clicked
isRTL
booleanfalseWhether text direction is RTL

Accessibility

Screen Reader

The component uses semantic HTML with proper ARIA attributes. The role, timestamp, and content are all announced correctly.

Keyboard Navigation

  • Tab: Navigate through action buttons
  • Enter: Activate buttons (Copy, Regenerate)

RTL Considerations

Chat messages automatically adapt to RTL layout. User messages align to the end (right in RTL), and assistant messages to the start (left in RTL). Set isRTL prop for RTL-specific text.

LTR (English)

2:30 PM

Hello! How can I help you today?

RTL (العربية)

٢:٣٠ م

مرحباً! كيف يمكنني مساعدتك اليوم؟

Related Components

Prompt Input

Input component for sending chat messages

Message Actions

Action buttons for chat messages

Thinking Indicator

Loading state for AI responses