{"id":23785132,"url":"https://github.com/eyalzh/react-headless-chatbox","last_synced_at":"2026-04-27T00:32:06.238Z","repository":{"id":197577689,"uuid":"698922371","full_name":"eyalzh/react-headless-chatbox","owner":"eyalzh","description":"Headless chatbox React component","archived":false,"fork":false,"pushed_at":"2023-10-06T12:04:48.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-29T21:02:19.868Z","etag":null,"topics":["chatbox","headless","react"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/eyalzh.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}},"created_at":"2023-10-01T11:52:57.000Z","updated_at":"2023-10-04T09:36:14.000Z","dependencies_parsed_at":"2023-10-05T10:31:51.147Z","dependency_job_id":null,"html_url":"https://github.com/eyalzh/react-headless-chatbox","commit_stats":null,"previous_names":["eyalzh/react-headless-chatbox"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eyalzh/react-headless-chatbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyalzh%2Freact-headless-chatbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyalzh%2Freact-headless-chatbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyalzh%2Freact-headless-chatbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyalzh%2Freact-headless-chatbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eyalzh","download_url":"https://codeload.github.com/eyalzh/react-headless-chatbox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eyalzh%2Freact-headless-chatbox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32318417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"ssl_error","status_checked_at":"2026-04-26T23:26:25.802Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["chatbox","headless","react"],"created_at":"2025-01-01T13:14:41.223Z","updated_at":"2026-04-27T00:32:06.224Z","avatar_url":"https://github.com/eyalzh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Headless Chatbox\n\nA simple headless chatbox React component that consists of:\n- A messages container that is scrolled automatically\n- Chat messages that are styled differently per participant in the chat (e.g. aligned left/right)\n- A textbox that grows with content and is cleared after submission\n- A send button\n\nWith this headless implementation, you can fully style and position the messages, the textbox and the trigger.\n\n## Example\n\n\u003cimg src=\"https://s3.eu-west-1.amazonaws.com/simple.kanban/chatbox-demo2.png\" width=\"400\" alt=\"Chatbox demo\" /\u003e\n\n\n## Install\n\n```bash\nnpm install react-headless-chatbox\n```\n\n```bash\nyarn add react-headless-chatbox\n```\n\n## Code Example\n\nThe following code example uses tailwind to style the chatbox, as shown in the image above:\n\n```jsx\nimport { useState } from \"react\";\nimport { Chatbox, Message as ChatboxMessage, Participant as ChatboxParticipant } from \"react-headless-chatbox\";\nimport { ReactComponent as TriggerSVG } from \"./trigger.svg\";\n\ninterface Participant extends ChatboxParticipant {\n  // Add custom properties here\n}\n\ninterface Message extends ChatboxMessage {\n  id: string;\n  text: string;\n  // Add more properties here\n}\n\nconst PARTICIPANTS = [\n  { id: \"john\", side: \"left\"},\n  { id: \"jane\", side: \"right\" },\n] satisfies Participant[];\n\nconst MESSAGES = [\n  {\n    id: \"1\",\n    participantId: \"john\",\n    text: \"Hello, Jane!\",\n  },\n  {\n    id: \"2\",\n    participantId: \"jane\",\n    text: \"Hi, John!\",\n  },\n] satisfies Message[];\n\nfunction MyChatbox() {\n  const [messages, setMessages] = useState(MESSAGES);\n\n  const onMessageSend = (text: string) =\u003e {\n    const newMessage = {\n      id: Math.random().toString(),\n      participantId: \"jane\",\n      text,\n    };\n    setMessages((prevMessages) =\u003e [...prevMessages, newMessage]);\n  };\n\n  return (\n    \u003cdiv className=\"w-full h-full bg-white\"\u003e\n      \u003cChatbox\n        participants={PARTICIPANTS}\n        messages={messages}\n        onMessageSend={onMessageSend}\n        className=\"m-20 border-2 border-gray-200 rounded-md shadow-md w-96 h-96 relative overflow-hidden\"\n      \u003e\n        \u003cdiv className=\"bg-blue-800 p-4 text-white rounded-t-md\"\u003e\n          Jane (online)\n        \u003c/div\u003e\n        \u003cChatbox.Messages className=\"p-2 flex-1\"\u003e\n          {messages.map((message) =\u003e (\n            \u003cChatbox.Message\n              key={message.id}\n              message={message}\n              className={(participant) =\u003e {\n                return `p-2 rounded-md shadow-md m-2 ${\n                  participant.side === \"right\"\n                    ? \"bg-blue-600 text-white ml-8\"\n                    : \"bg-gray-200 text-gray-900 mr-8\"\n                }`;\n              }}\n            \u003e\n              {message.text}\n            \u003c/Chatbox.Message\u003e\n          ))}\n        \u003c/Chatbox.Messages\u003e\n        \u003cChatbox.Textbox className=\"block self-stretch m-2 bg-gray-100 py-2 pl-3 pr-9 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6 outline-none\" /\u003e\n        \u003cChatbox.Trigger className=\"cursor-pointer absolute bottom-3.5 right-3\"\u003e\n          \u003cTriggerSVG className=\"w-7 h-7 text-gray-400\" /\u003e\n        \u003c/Chatbox.Trigger\u003e\n      \u003c/Chatbox\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\nThe trigger.svg file:\n\n```svg\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003csvg fill=\"currentColor\" version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" \n\t viewBox=\"0 0 24 24\" xml:space=\"preserve\"\u003e\n\u003cstyle type=\"text/css\"\u003e\n\t.st0{fill:none;}\n\u003c/style\u003e\n\u003cg id=\"surface1\"\u003e\n\t\u003cpath d=\"M2,3v7.8L18,12L2,13.2V21l20-9L2,3z\"/\u003e\n\u003c/g\u003e\n\u003crect class=\"st0\" width=\"24\" height=\"24\"/\u003e\n\u003c/svg\u003e\n```\n\n## API\n\n### Chatbox\n\n| Prop Name | Type | Description |\n| --- | --- | --- |\n| `onMessageSend` | `(text: string) =\u003e void` | Callback function to be called when the user submits a message. |\n| `messages` | `Array\u003cMessage\u003e` | An array of `Message` objects to display in the chatbox. |\n| `participants` | `Array\u003cParticipant\u003e` | An array of `Participant` objects representing the participants in the chat. |\n| `autoScrollDown?` | `boolean` | If true, the container will scroll down automatically (default: true). |\n| `className` | `string` | Additional CSS classes to apply to the component. |\n| `style` | `React.CSSProperties` | Inline styles to apply to the component. |\n| `ref` | `React.Ref\u003cHTMLDivElement\u003e` | ref object to the HTML container element. |\n\n### Chatbox.Messages:\n\n| Prop Name | Type | Description |\n| --- | --- | --- |\n| `className` | `string` | Additional CSS classes to apply to the component. |\n| `style` | `React.CSSProperties` | Inline styles to apply to the component. |\n\n### Chatbox.Message:\n\n| Prop Name | Type | Description |\n| --- | --- | --- |\n| `message` | `Message` | The message object being rendered |\n| `className` | `string \\| ((participant: Participant) =\u003e string);` | Additional CSS classes to apply to the component. You can also use the function to style each message based on the participant |\n| `style` | `React.CSSProperties` | Inline styles to apply to the component. |\n\n### Chatbox.Textbox:\n\n| Prop Name | Type | Description |\n| --- | --- | --- |\n| `ref` | `React.Ref\u003cHTMLTextAreaElement \\| null\u003e` | ref object to the textarea element. |\n| `className` | `string` | Additional CSS classes to apply to the component. |\n| `style` | `React.CSSProperties` | Inline styles to apply to the component. |\n| `placeholder` | `string` | Placeholder text to display in the textarea. |\n| `maxLength` | `number` | Maximum number of characters allowed in the textarea. |\n| `onChange` | `ChangeEventHandler\u003cHTMLTextAreaElement\u003e` | Callback function to be called when the value of the textarea changes. |\n| `aria-label` | `string` | ARIA label for the textarea (default: \"Message to send\"). |\n\n### Chatbox.Trigger\n\n| Prop Name | Type | Description |\n| --- | --- | --- |\n| `ref` | `React.Ref\u003cHTMLButtonElement\u003e` | ref object to the button element. |\n| `className` | `string` | Additional CSS classes to apply to the component. |\n| `style` | `React.CSSProperties` | Inline styles to apply to the component. |\n| `aria-label` | `string` | ARIA label for the button (default: \"Send Message\"). |\n\n## See also\n\n[React Headless Gallery](https://github.com/eyalzh/react-headless-gallery)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feyalzh%2Freact-headless-chatbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feyalzh%2Freact-headless-chatbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feyalzh%2Freact-headless-chatbox/lists"}