Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-chat-elements

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-chat-elements

Reactjs chat components

  • 0.4.22
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by11.87%
Maintainers
1
Weekly downloads
 
Created
Source

react-chat-elements

Reactjs chat elements

Install

npm install react-chat-elements@latest --save

Imports

// RCE CSS
import 'react-chat-elements/dist/main.css';
// MessageBox component
import {MessageBox} from 'react-chat-elements';

Components

  1. ChatItem
  2. MessageBox
  3. SystemMessage
  4. MessageList
  5. ChatList
  6. Input
  7. Button
  8. Popup
  9. SideBar
  10. Navbar
  11. Dropdown
  12. Avatar

ChatItem Component

chatitem-photo

import { ChatItem } from 'react-chat-elements'

<ChatItem
    avatar={'https://facebook.github.io/react/img/logo.svg'}
    alt={'Reactjs'}
    title={'Facebook'}
    subtitle={'What are you doing?'}
    date={new Date()}
    unread={0} />
ChatItem props
propdefaulttypedescription
avatarnonestringChatItem avatar photo url
avatarFlexiblefalsebooleanflexible ChatItem avatar photo
altnonestringChatItem avatar photo alt text
titlenonestringChatItem title
subtitlenonestringChatItem subtitle
datenonedateChatItem date
unread0intChatItem unread count
onClicknonefunctionChatItem on click
statusColornonecolorChatItem status color
statusTextnonecolorChatItem status text

MessageBox Component

filephototext
file-messagephoto-message  text-message
import { MessageBox } from 'react-chat-elements'

<MessageBox
    position={'left'}
    type={'photo'}
    text={'react.svg'}
    data={{
        uri: 'https://facebook.github.io/react/img/logo.svg',
        status: {
            click: false,
            loading: 0,
        }
    }}/>
MessageBox props
propdefaulttypedescription
idi (index)string message box id
position leftstring message box position
type textstring message type (text, photo, file)
textnonestring message text
titlenonestring message title
titleColornonestring(color) message title color
data {}objectmessage data
datenew Date()Datemessage date
onClicknonefunctionmessage on click (message(object) is returned)
onOpennonefunctionmessage on open (file or photo) (message(object) is returned)
onDownloadnonefunctionmessage on download (file or photo) (message(object) is returned)
onTitleClicknonefunctionmessage title on click event

SystemMessage Component

import { SystemMessage } from 'react-chat-elements'

<SystemMessage
    text={'End of conversation'}/>
SystemMessage props
propdefaulttypedescription
textnonestring message text

MessageList Component

messagelist-photo

import { MessageList } from 'react-chat-elements'

<MessageList
    className='message-list'
    lockable={true}
    toBottomHeight={'100%'}
    dataSource={[
        {
            position: 'right',
            type: 'text',
            text: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit',
            date: new Date(),
        },
        .
        .
        .
    ]} />
MessageList props
propdefaulttypedescription
classNamenonestringoptional message list className
dataSource[]arraymessage list array
lockablefalsebooleanIt locks to scroll position when the dataSource has been changed
toBottomHeight300int or string(only '100%')If the toBottomHeight property's value higher than bottom value of the scrollbar when the data source has been changed Scrollbar goes to bottom at the end of the page. If the toBottomHeight property's value has been set '100%', scrollbar goes to bottom at the end of the page when the data source has been changed.
onClicknonefunctionmessage list item on click (message(object) is returned)
onOpennonefunctionmessage list item on open (file or photo) (message(object) is returned)
onDownloadnonefunctionmessage list item on download (file or photo) (message(object) is returned)
onScrollnonefunctionmessage list onScroll event

ChatList Component

chatlist-photo

import { ChatList } from 'react-chat-elements'

<ChatList
    className='chat-list'
    dataSource={[
        {
            avatar: 'https://facebook.github.io/react/img/logo.svg',
            alt: 'Reactjs',
            title: 'Facebook',
            subtitle: 'What are you doing?',
            date: new Date(),
            unread: 0,
        },
        .
        .
        .
    ]} />
ChatList props
propdefaulttypedescription
classNamenonestringoptional chat list className
dataSource[]arraychat list array
onClicknonefunctionchat list item on click (chat(object) is returned)

Input Component

import { Input } from 'react-chat-elements'

<Input
    placeholder="Type here..."
    multiline={true}
    buttons={
        <Button
            color='white'
            backgroundColor='black'
            text='Send'/>
    }/>

// clear text eg:
<Input
    ref='input'
    placeholder="Type here..."/>

this.refs.input.clear();
Input props
propdefaulttypedescription
classNamenonestringoptional input className
placeholdernonestringinput placeholder text
defaultValuenonestringinput default value
onChangenonefunctioninput onChange function
multilinefalseboolinput is textarea
autoHeighttrueboolinput auto height
minHeight25intinput min height
maxHeight200intinput max height
inputStylenoneobjectinputStyle object
leftButtonsnoneobject(component)left buttons component
rightButtonsnoneobject(component)right buttons component
inputRefnonefunctioninput or textarea ref

Button Component

import { Button } from 'react-chat-elements'

<Button
    text={'click me!'} />
Button props
propdefaulttypedescription
typenonestringbutton type (outlined, transparent)
disablednonestringbutton is disabled?
textnonestringbutton text
buttonRefnonefunctionbutton ref

Popup Component

import { Popup } from 'react-chat-elements'

<Popup
    show={this.state.show}
    header='Lorem ipsum dolor sit amet.'
    headerButtons={[{
        type: 'transparent',
        color:'black',
        text: 'close',
        onClick: () => {
            this.setState({show: false})
        }
    }]}
    text='Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem animi veniam voluptas eius!'
    footerButtons={[{
        color:'white',
        backgroundColor:'#ff5e3e',
        text:"Vazgeç",
    },{
        color:'white',
        backgroundColor:'lightgreen',
        text:"Tamam",
    }]}/>
Popup props
propdefaulttypedescription
showfalseboolpopup visible
headernonestringpopup title (header) message
headerButtonsnonearraypopup title (header) buttons
textnonestringpopup content (center) message
color#333string (color)popup content message color
footerButtonsnonearraypopup footer buttons
renderHeadernonefunction (component)render header function
renderContentnonefunction (component)render content function
renderFooternonefunction (component)render footer function

SideBar Component

import { SideBar } from 'react-chat-elements'

<SideBar
    top={
        <div>'TOP' area</div>
    }
    center={
        <div>'CENTER' area</div>
    }
    bottom={
        <div>'BOTTOM' area</div>
    }/>
SideBar props
propdefaulttypedescription
typedarkstringpopup visible
topfalsefunction (component)popup top component
centernonefunction (component)popup center component
bottomnonefunction (component)popup bottom component

Navbar Component

import { Navbar } from 'react-chat-elements'

<Navbar
    top={
        <div>'TOP' area</div>
    }
    center={
        <div>'CENTER' area</div>
    }
    bottom={
        <div>'BOTTOM' area</div>
    }/>
Navbar props
propdefaulttypedescription
typedarkstringpopup visible
topfalsefunction (component)popup top component
centernonefunction (component)popup center component
bottomnonefunction (component)popup bottom component

Dropdown Component

import { Dropdown } from 'react-chat-elements'

<Dropdown
    buttonProps={{
        text: 'Dropdown',
    }}
    items={[
        'merhaba',
        'lorem',
        'ipsum',
        'dolor',
        'sit',
        'amet',
    ]}/>
Dropdown props
propdefaulttypedescription
animationTypenonestringfade or default
animationPositionnortweststringanimation start position (nortwest, norteast, southwest, southeast)
itemsnonearraydropdown items array
onSelectnonefunctionitem on select
buttonPropsnoneobjectbutton properties

Avatar Component

import { Avatar } from 'react-chat-elements'

<Avatar
    src={'https://facebook.github.io/react/img/logo.svg'}
    alt={'logo'}
    size="large"
    type="circle flexible"/>
Avatar props
propdefaulttypedescription
srcnoneimageimage src
altnonestringimage alt description
sizedefaultstringimage size. default (25px), xsmall(30px), small(35px), medium(40px), large(45px), xlarge (55px)
typedefaultstringtypes: default, circle, rounded(border radius 5px), flexible
sideElementnonecomponentavatar side element

Keywords

FAQs

Package last updated on 18 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc