项目作者: alibaba

项目描述 :
The UI design language and React library for Conversational UI
高级语言: TypeScript
项目地址: git://github.com/alibaba/ChatUI.git
创建时间: 2020-08-04T03:09:19Z
项目社区:https://github.com/alibaba/ChatUI

开源协议:MIT License

下载




ChatUI

The UI design language and React library for Conversational UI

Website:https://chatui.io



LICENSE
NPM version
NPM downloads
Gzip Size
Jsdelivr Hits



English | 简体中文

Features

  • 😎 Best Practices: The best practice for chat interaction based on our experience of Alime Chatbot
  • 🛡 TypeScript: Written in TypeScript with predictable static types
  • 📱 Responsive: Responsive design to adapt automatically to whatever device
  • Accessibility: Accessibility support and get the certification from Accessibility Research Association
  • 🎨 Theming: Powerful theme customization in every detail
  • 🌍 International: Internationalization support for dozens of languages

Environment Support

Edge
Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Android WebView
Android WebView
16+ 31+ 49+ 9.1+ 9.3+ 6+

Install

  1. npm install @chatui/core --save
  1. yarn add @chatui/core

Usage

  1. import Chat, { Bubble, useMessages } from '@chatui/core';
  2. import '@chatui/core/dist/index.css';
  3. const App = () => {
  4. const { messages, appendMsg, setTyping } = useMessages([]);
  5. function handleSend(type, val) {
  6. if (type === 'text' && val.trim()) {
  7. appendMsg({
  8. type: 'text',
  9. content: { text: val },
  10. position: 'right',
  11. });
  12. setTyping(true);
  13. setTimeout(() => {
  14. appendMsg({
  15. type: 'text',
  16. content: { text: 'Bala bala' },
  17. });
  18. }, 1000);
  19. }
  20. }
  21. function renderMessageContent(msg) {
  22. const { content } = msg;
  23. return <Bubble content={content.text} ></Bubble>;
  24. }
  25. return (
  26. <Chat
  27. navbar={{ title: 'Assistant' }}
  28. messages={messages}
  29. renderMessageContent={renderMessageContent}
  30. onSend={handleSend}
  31. ></Chat>
  32. );
  33. };

DEMO

Development

  1. cd demo
  2. npm i
  3. npm run dev

Theme

Visit Customize Theme for detail

Internationalization

Visit i18n for detail

License

MIT