{"id":21593068,"url":"https://github.com/peterkottas/react-bell-chat","last_synced_at":"2025-04-10T23:32:41.126Z","repository":{"id":32288897,"uuid":"131038669","full_name":"PeterKottas/react-bell-chat","owner":"PeterKottas","description":":bell: Easy to use chat user interface for React","archived":false,"fork":false,"pushed_at":"2023-07-08T13:37:46.000Z","size":3996,"stargazers_count":54,"open_issues_count":16,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-23T09:13:09.444Z","etag":null,"topics":["chat","chat-application","chatapp","react","reactjs","ux-ui"],"latest_commit_sha":null,"homepage":"https://peterkottas.github.io/react-bell-chat/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PeterKottas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-25T17:04:27.000Z","updated_at":"2024-07-17T15:11:53.000Z","dependencies_parsed_at":"2024-06-21T07:13:02.018Z","dependency_job_id":"9b28914d-3053-4638-98b3-65e1025d1bb9","html_url":"https://github.com/PeterKottas/react-bell-chat","commit_stats":null,"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterKottas%2Freact-bell-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterKottas%2Freact-bell-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterKottas%2Freact-bell-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterKottas%2Freact-bell-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterKottas","download_url":"https://codeload.github.com/PeterKottas/react-bell-chat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248316837,"owners_count":21083515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat","chat-application","chatapp","react","reactjs","ux-ui"],"created_at":"2024-11-24T17:11:12.076Z","updated_at":"2025-04-10T23:32:41.102Z","avatar_url":"https://github.com/PeterKottas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :bell: react-bell-chat\n\nA library of React components for building chat UIs.\n\n# DEMO\n\n[Live demo](https://peterkottas.github.io/react-bell-chat/)\n\n[![NPM](https://nodei.co/npm/react-bell-chat.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/react-bell-chat/)\n\n## Features\n\n* Chat like scroll behavior (eg. automatic scroll to bottom)\n* Load more messages on scrolling to the top (with custom threshold)\n* SUPER easy to use\n* Customize anything\n* Author avatars\n* Last seen messages for each author\n* Show if authors are typing or not\n* Automatic date rows (when the following message is from a different date than the preceding one)\n\nKeep in mind that this project is still in the early stages of development. If you encounter a bug or have a feature request, please create an issue.\n\n## Installation\n\n`npm install react-bell-chat --save`\n\nOR\n\n`yarn add react-bell-chat`\n\n## Basic Usage\n\n```typescript\nimport { ChatFeed } from 'react-bell-chat'\n\n// Your code stuff...\n\nrender() {\n\n  return (\n\n    // Your JSX...\n\n    \u003cChatFeed\n      messages={this.state.messages} // Array: list of message objects\n      authors={this.state.authors} // Array: list of authors\n      yourAuthorId={2} // Number: Your author id (corresponds with id from list of authors)\n    /\u003e\n\n    // Your JSX...\n\n  )\n\n}\n```\n\nThe bare minimum is to provide a list of messages and authors, check this out for an example:\n\n```typescript\n//...\nthis.state = {\n  messages: [\n    {\n      id: 1,\n      authorId: 1,\n      message: \"Sample message\",\n      createdOn: new Date(),\n      isSend: true\n    },\n    {\n      id: 2,\n      authorId: 2,\n      message: \"Second sample message\",\n      createdOn: new Date(),\n      isSend: false\n    },\n  ],\n  authors: [\n    {\n      id: 1,\n      name: 'Mark',\n      isTyping: true,\n      lastSeenMessageId: 1,\n      bgImageUrl: undefined\n    },\n    {\n      id: 2,\n      name: 'Peter',\n      isTyping: false,\n      lastSeenMessageId: 2,\n      bgImageUrl: undefined\n    }\n  ]\n};\n//...\n```\n\nComplete props for author:\n\ntypescript\n```\nexport interface Author {\n    id: number;\n    name: string;\n    avatarName?: string;\n    lastSeenAvatarName?: string;\n    isTyping?: boolean;\n    lastSeenMessageId?: number;\n    bgImageUrl?: number;\n}\n```\n\nComplete props for message:\n\ntypescript\n```\nexport interface Message {\n  id?: number;\n  authorId?: number; // If undefined, message is considered to be \"System message\"\n  message: string;\n  createdOn?: Date;\n  isSend?: boolean;\n}\n```\n\n## API\n\nApi is obtained as ref of the ChatFeed component. It's divided in 2 parts, feedApi and scrollApi. Ref gives you and object like this:\n```typescript\ninterface ChatFeedApi {\n  onMessageSend: () =\u003e void; // Should be called when user sends a message (this scrolls the component down)\n  scrollApi: ChatScrollAreaApi;\n}\n```\n\nWhere scroll api is\n\n```typescript\ninterface ChatScrollAreaApi {\n  scrollToBottom: (behavior?: ScrollBehavior) =\u003e void;\n  scrollTo: (top: number) =\u003e void;\n  scrolledToBottom: () =\u003e boolean; // Check if we are scrolled to bottom\n  scrolledToLoadThreshold: () =\u003e boolean; // Check if we are scrolled to threshold where we need to load messages\n}\n```\n\n## Whole list of properties\n\n```typescript\nexport interface ChatFeedProps {\n  // Structural props\n  className?: string;\n\n  // Functional props\n  messages: Message[];\n  authors: Author[];\n  yourAuthorId: number;\n  hasOldMessages?: boolean;\n  loadOldMessagesThreshold?: number;\n\n  // Visual props\n  bubblesCentered?: boolean;\n  bubbleStyles?: ChatBubbleStyles;\n  maxHeight?: string | number;\n  minHeight?: string | number;\n\n  // Switches\n  showDateRow?: boolean;\n  showRecipientAvatar?: boolean;\n  showRecipientLastSeenMessage?: boolean;\n  showIsTyping?: boolean;\n  showLoadingMessages?: boolean;\n\n  // Extra container styles for custom components\n  showRecipientAvatarChatMessagesStyle?: React.CSSProperties;\n  showRecipientLastSeenMessageChatMessagesStyle?: React.CSSProperties;\n  showIsTypingChatMessagesStyle?: React.CSSProperties;\n\n  // Custom components\n  customLoadingMessages?: (props: LoadingMessagesProps) =\u003e JSX.Element;\n  customChatBubble?: (props: ChatBubbleProps) =\u003e JSX.Element;\n  customSystemChatBubble?: (props: ChatBubbleProps) =\u003e JSX.Element;\n  customAvatar?: (props: AvatarProps) =\u003e JSX.Element;\n  customScrollArea?: (props: ChatScrollAreaProps) =\u003e JSX.Element;\n  customIsTyping?: (props: ChatScrollAreaProps) =\u003e JSX.Element;\n  customLastSeenAvatar?: (props: LastSeenAvatarProps) =\u003e JSX.Element;\n  customDateRow?: (props: DateRowProps) =\u003e JSX.Element;\n\n  // Callbacks\n  onLoadOldMessages?: () =\u003e Promise\u003cvoid\u003e; // Make sure to return promise that only resolves after state is updated.\n\n  ref?: (api: ChatFeedApi) =\u003e void;\n}\n```\n\n## Custom components\n\nMost of the UI is customizable via injecting custom components. These are pure components, the library injects props to them so that you can customize pretty much anything.\n\n## FAQ\n\nQ: My chat is scrolling up/down automatically every time I use setState on parent component.\n\nA: Make sure to provide const expressions for custom components. Not inline functions.\n\n## Created and sponsored by\n\n- [GuestBell](https://guestbell.com/) - Customer centric online POS for Hotels and short terms stays.\n\n## Contributing 🔧\n\nContributions are always welcomed and encouraged.\n\n## Development\n\n```sh\nnpm run start\n```\n\n## Acknowledgments\n\nThis lib started as a fork from https://github.com/brandonmowat/react-chat-ui\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterkottas%2Freact-bell-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterkottas%2Freact-bell-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterkottas%2Freact-bell-chat/lists"}