The UI design language and React library for Conversational UI
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](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png) Edge | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) Firefox | ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) Chrome | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png) Safari | ![iOS Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari-ios/safari-ios_48x48.png) iOS Safari | ![Android WebView](https://raw.githubusercontent.com/alrra/browser-logos/master/src/android-webview/android-webview_48x48.png) Android WebView |
---|
16+ | 31+ | 49+ | 9.1+ | 9.3+ | 6+ |
Install
npm install @samagra-x/chatui
yarn add @samagra-x/chatui
Usage
import Chat, { Bubble, useMessages } from '@samagra-x/chatui';
import '@samagra-x/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: 'Assistant' }}
messages={messages}
renderMessageContent={renderMessageContent}
onSend={handleSend}
/>
);
};
![DEMO](https://codesandbox.io/static/img/play-codesandbox.svg)
Development
cd storybook
npm i
npm run storybook
License
MIT