Skip to content
/ ChatUI Public
forked from alibaba/ChatUI

The UI design language and React library for Conversational UI

License

Notifications You must be signed in to change notification settings

pre868/ChatUI

Repository files navigation

ChatUI

服务于智能对话领域的设计和开发体系,助力智能对话机器人的搭建

安装

npm install chatui --save
yarn add chatui

示例

import Chat, { Bubble, useMessages } from 'chatui';
import 'chatui/dist/index.css';

const App = () => {
  const { messages, appendMsg, setTyping } = useMessages([]);

  function handleSend(type, val) {
    if (type === 'text' && val.trim()) {
      appendMsg({
        type: 'text',
        content: { text: val },
        position: 'right',
      });

      setTyping(true);

      setTimeout(() => {
        appendMsg({
          type: 'text',
          content: { text: 'Bala bala' },
        });
      }, 1000);
    }
  }

  function renderMessageContent(msg) {
    const { content } = msg;
    return <Bubble content={content.text} />;
  }

  return (
    <Chat
      navbar={{ title: '智能助理' }}
      messages={messages}
      renderMessageContent={renderMessageContent}
      onSend={handleSend}
    />
  );
};

定制主题

参考 定制主题 文档。

国际化

参考 国际化 文档。

License

MIT

About

The UI design language and React library for Conversational UI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 80.4%
  • Less 18.0%
  • JavaScript 1.6%