Catalog npm
Back to packageRELEASE DETAILS

1.0.8

npm

@0xbot/chat-react

A React component for building chat interfaces with streaming support.

Published19 Apr 2025
Direct dependencies21
Transitive dependenciesNot calculated

README

Current package documentation

Chat Library React

A React component for building chat interfaces with streaming support.

Installation

npm install @0xbot/chat-react
# or
yarn add @0xbot/chat-react
# or
pnpm add @0xbot/chat-react

Usage

import React from 'react'
import { ChatLibrary } from '@0xbot/chat-react'
import '@0xbot/chat-react/dist/index.css' // Import the CSS

const App = () => {
  return (
    <ChatLibrary
      apiKey="your-api-key"  // required  
      serverUrl="your-server-url" // not required
      UserAvatar={<YourUserAvatar />} // required
      AgentAvatar={<YourAgentAvatar />} // required
      loadingText="AI is thinking..." // not required
      emptyText="No messages yet" // not required
      tradeApiKey="xxxx-xxxx-xx"
    />
  )
}

export default App

Props

PropTypeRequiredDefaultDescription
apiKeystringYes-Your API key for authentication
serverUrlstringYes-The server URL for API requests
UserAvatarReactNodeYes-The avatar component for user messages
AgentAvatarReactNodeYes-The avatar component for agent messages
loadingTextstringNo'AI is thinking...'Text to display while loading
emptyTextstringNo'No messages yet'Text to display when there are no messages
themeobjectNo{}Theme configuration object
tradeApiKeystringNo''trade api key

Features

  • Real-time message streaming
  • Markdown support
  • Customizable theme
  • Responsive design
  • Built-in loading states
  • Error handling

Dependencies

This library requires the following peer dependencies:

  • React 18 or higher
  • React DOM 18 or higher
  • @types/react 18 or higher (for TypeScript projects)
  • @types/react-dom 18 or higher (for TypeScript projects)

Styling

You can customize the appearance of the chat component by overriding the following CSS classes:

/* Main container */
.chat-library {
  box-sizing: border-box;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

/* Bottom bar */
.chat-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Input field */
.chat-bar-input {
  flex: 1;
  height: 44px;
  outline: none;
  border-radius: 99999px;
  border: 1px solid #ccc;
  background-color: transparent;
  color: #fff;
  padding: 0 16px;
  min-width: 0;
}

/* Send button */
.chat-bar-send {
  flex: none;
  width: auto;
  border: 1px solid;
  height: 48px;
  padding: 0 32px;
  border-radius: 99999px;
  cursor: pointer;
  background-color: transparent;
  transition: all 0.2s ease-in-out;
}

/* Send button hover */
.chat-bar-send:hover {
  background-color: var(--primary-color);
  color: white !important;
}

/* Chat container (excluding bottom bar) */
.chat-container {
  flex: 1;
  overflow-y: scroll;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Hide scrollbar */
.chat-container::-webkit-scrollbar {
  display: none;
}

/* Chat message list */
.chat-container-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message bubble */
.message-bubble {
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 90%;
  font-size: 14px;
  word-break: break-all;
  line-height: 24px;
}

@media (min-width: 768px) {
  .message-bubble {
    max-width: 70%;
    font-size: 13px;
  }
}

/* Avatar */
.chat-avatar {
  width: 44px;
  height: 44px;
  max-width:44px;
  max-height:44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
}

/* Message bubble background */
.chat-message {
  background-color: rgba(255, 255, 255, 0.1)
}

/* Message container */
.message-container {
  display: flex;
}

/* Delete button */
.chat-bar-trash {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  color: #fff;
  cursor: pointer;
}

/* Loading state */
.message-loading {
  color: #fff;
  font-style: italic;
}

/* Empty message state */
.message-empty {
  color: #fff;
  font-style: italic;
  text-align: center;
}

/* Trade modal */
.dodo-swap {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

How to Override Styles

You can override these styles by adding your own CSS rules after importing the library's CSS. For example:

/* Import the library's CSS first */
@import '@0xbot/chat-react/dist/index.css';

/* Then add your custom styles */
.chat-bar-input {
  border-color: #ff0000;
  background-color: #f0f0f0;
  color: #333;
}

.chat-bar-send {
  background-color: #4CAF50;
  color: white;
  border: none;
}

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 27

Native requirements
21 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^1.6.7runtime
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^22.14.1runtime
localforage
Environment
{
  "local_name": "localforage",
  "alias": false,
  "peer_metadata": null
}
^1.10.0runtime
markdown-it
Environment
{
  "local_name": "markdown-it",
  "alias": false,
  "peer_metadata": null
}
^14.0.0runtime
highlight.js
Environment
{
  "local_name": "highlight.js",
  "alias": false,
  "peer_metadata": null
}
^11.9.0runtime
@unocss/reset
Environment
{
  "local_name": "@unocss/reset",
  "alias": false,
  "peer_metadata": null
}
^0.63.3runtime
@fingerprintjs/fingerprintjs
Environment
{
  "local_name": "@fingerprintjs/fingerprintjs",
  "alias": false,
  "peer_metadata": null
}
^4.2.1runtime
vite
Environment
{
  "local_name": "vite",
  "alias": false,
  "peer_metadata": null
}
^5.1.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.56.0development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.2.2development
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^18.2.55development
vite-plugin-dts
Environment
{
  "local_name": "vite-plugin-dts",
  "alias": false,
  "peer_metadata": null
}
^3.7.1development
@types/react-dom
Environment
{
  "local_name": "@types/react-dom",
  "alias": false,
  "peer_metadata": null
}
^18.2.19development
@types/markdown-it
Environment
{
  "local_name": "@types/markdown-it",
  "alias": false,
  "peer_metadata": null
}
^14.1.2development
@vitejs/plugin-react
Environment
{
  "local_name": "@vitejs/plugin-react",
  "alias": false,
  "peer_metadata": null
}
^4.2.1development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^6.21.0development
eslint-plugin-react-hooks
Environment
{
  "local_name": "eslint-plugin-react-hooks",
  "alias": false,
  "peer_metadata": null
}
^4.6.0development
eslint-plugin-react-refresh
Environment
{
  "local_name": "eslint-plugin-react-refresh",
  "alias": false,
  "peer_metadata": null
}
^0.4.5development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^6.21.0development
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^1.6.7peer
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^18.2.0peer
react-dom
Environment
{
  "local_name": "react-dom",
  "alias": false,
  "peer_metadata": null
}
^18.2.0peer
localforage
Environment
{
  "local_name": "localforage",
  "alias": false,
  "peer_metadata": null
}
^1.10.0peer
markdown-it
Environment
{
  "local_name": "markdown-it",
  "alias": false,
  "peer_metadata": null
}
^14.0.0peer
highlight.js
Environment
{
  "local_name": "highlight.js",
  "alias": false,
  "peer_metadata": null
}
^11.9.0peer
@unocss/reset
Environment
{
  "local_name": "@unocss/reset",
  "alias": false,
  "peer_metadata": null
}
^0.58.5peer
@fingerprintjs/fingerprintjs
Environment
{
  "local_name": "@fingerprintjs/fingerprintjs",
  "alias": false,
  "peer_metadata": null
}
^4.2.1peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "79bc19256c78c3b88f09c7bbd3d70370611a9ca4",
  "tarball": "https://registry.npmjs.org/@0xbot/chat-react/-/chat-react-1.0.8.tgz",
  "fileCount": 17,
  "integrity": "sha512-WeeetMdf/zqCHcFwmlY2+DrvbWoTGZG0LE39SIX4QzBMKTtI1E9HIaIQM8PpMxanyCsAZnV4EJN1Yi9158csMQ==",
  "signatures": [
    {
      "sig": "MEUCIFcq0u+MXTtDENhk/6FWJh5fxfp1kYpT7ol2ZlKHjpsXAiEAvFuxRc1Y08X9I0OHLd/MxatqHcQOiGazzHIE/9qlyQo=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 69347
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:ca27f32f3a5604ec65cd4c67e5de97ad092b538d049f5ba6b982f57a082a81da

Other collected versions

1.0.1623 Dec1.0.1516 Dec1.0.1410 Jul1.0.1324 Jun1.0.1217 Jun1.0.1117 JunView all collected versions →