1.1.4 • Published 3 years ago

react-simple-chat v1.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

react-simple-chat

Simple chat component for React.js

Install

npm i react-simple-chat

Imports

// Chat component
import Chat, { Message } from 'react-simple-chat';
// Chat styles
import 'react-simple-chat/src/components/index.css';

Example

const [messages, setMessages] = useState<Message[]>([
    {
        id: 1,
        text: 'Hello my friend!',
        createdAt: '2021-07-21 12:09:12', // optional
        user: {
            id: 2,
            avatar: 'https://link-to-avatar/avatar.jpg' // optional
        }
    }
]);

<Chat
    title="Jane Doe"
    user={{ id: 1 }}
    messages={messages}
    onSend={message => setMessages([...messages, message])}
/>

Chat props

propdefaulttypedescription
headerAvatarnonestringChat avatar photo url.
titleChat DemostringTitle of chat.
minimizedfalsebooleanDescribes if chat is minimized or not.
usernoneobjecte.g. user: { id: 1 }, User object needs to have id property which defines who sent the message.
onSendnonefunctionReturns message object when click send button.
messagesnonearrayList of messages
isTypingfalsebooleanShow typing indicator.
onInputTextChangednonefunctionReturns value of message input when text changed.
headerStylenoneobjectObject styles for header component.
titleColornonestringColor of title in header.
minimizeIconnonestringPath to custom minimize icon in header.
leftBubbleStylenoneobjectObject styles for left bubbles.
rightBubbleStylenoneobjectObject styles for right bubbles.
backgroundColornonestringBackground color of messages container.
timestampStylenoneobjectObject styles for timestamps.
inputToolbarStylenoneobjectObject styles for input toolbar.
inputStylenoneobjectObject styles for input.
sendIconnonestringPath to custom send icon.
chatIconnonestringPath to custom chat widget.
containerStylenoneobjectObject styles for the entire chat component.
widgetStylenoneobjectObject styles for chat widget.
1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago

0.1.0

5 years ago