0.6.1 • Published 3 years ago

react-custom-chat v0.6.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

react-custom-chat

react-custom-chat is a free and fully customizable chat window that can be easily included in any project.

Demo gif of react-custom-chat being used

Link to Repository

Demo

Table of Contents

Installation

$ npm install react-custom-chat

Example

import ChatBox from 'react-custom-chat'
import { useState } from 'react'

const App = () => {
  const [messageList, setMessageList] = useState([])

  const handleSendMessage = newMessage => {
    setMessageList([
      ...messageList,
      {text: newMessage, person: 'primary'}
    ])
  }

  return (
    <div>
      <ChatBox
        settings={{
          position: 'right',
          navColor: 'green',
          navText: 'Jane Doe',
        }}
        messageList={messageList}
        onSendMessage={handleSendMessage}
      />
    </div>
  )
}

Components

ChatBox

ChatBox props:

proptyperequireddescription
settingsobjectnoYou can use this prop to define custom settings for your chat window.
messageListarrayyesan array of objects for your messages. See message object here
isOpenbooleanyesForces the open/close state of the chat window. If this is not set, it will be closed by default, and open when the chat icon is clicked.
onSendMessagefunctionyesThe function's first parameter will be the message from the input field. see example for usage.

Settings properties:

propertytypedescription
positionstringThis indicates the position of your chat window. Value can be left or right. Default is right.
navColorstringYou can use this to customize your NavColor
primaryColorstringUse this to define the primary user color. You can choose from 'green', 'red', 'blue', etc...
secondaryColorstringUse this to define the primary user color. You can choose from 'green', 'red', 'blue', etc...
navTextstringThis is the text that shows up on the chat window header. The Default is 'Jane Doe'

Message Object

Each message is styled differently depending on its type. Currently, only text is supported. Each message object has a person property which can have the value 'primary' or 'secondary', and a text property which contains the message text.

{
  text: 'hello world!',
  person: 'primary',
}

Using react-custom-chat? Let's talk

If you're using react-custom-chat, I'd love to see what you're building! Send me a mail ebenezerdon.official@gmail.com

0.6.1

3 years ago

0.6.0

3 years ago

0.5.9

3 years ago

0.5.8

3 years ago

0.5.7

3 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.29

3 years ago

0.5.28

3 years ago

0.5.27

3 years ago

0.5.26

3 years ago

0.5.25

3 years ago

0.5.24

3 years ago

0.5.23

3 years ago

0.5.22

3 years ago

0.5.21

3 years ago

0.5.20

3 years ago

0.5.19

3 years ago

0.5.18

3 years ago

0.5.17

3 years ago

0.5.16

3 years ago

0.5.15

3 years ago

0.5.14

3 years ago

0.5.13

3 years ago

0.5.12

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago