Skip to content

Repository files navigation

🗨️ Floating Chat UI

A customizable, lightweight, and modern React floating chat component.
Perfect for support widgets, AI bots, or in-app messaging.


🚀 Features

  • 💬 Floating toggle button
  • 🧱 Fully customizable via styles prop
  • 🧠 Simulated bot response
  • 🔧 Custom header and footer support
  • 🎯 Per-message styling support
  • 📱 Responsive design
  • 🔋 Zero dependencies

📦 Installation

npm install floating-chat-ui

🧪 Usage with Props

Here’s how you can use all key props in one example:

importFloatingChatfrom'floating-chat-ui';functionApp(){return(<FloatingChatonSendMessage={(msg)=>console.log('User message:',msg)}messagePlaceholder="Type your message..."chatButtonText="💬"openButtonText="✖"headerText="Support Chat"sendButtonText="Send"botDefaultReply="Thank you! We’ll respond shortly."styles={{toggleButton: {backgroundColor: '#C4B0A9',color: '#fff'},header: {backgroundColor: '#E4F4DD',color: '#333'},sendButton: {backgroundColor: '#fff',color: '#C4B0A9',border: '1px solid #C4B0A9',},input: {borderColor: '#E4F4DD'},userMessage: {backgroundColor: '#C4B0A9',color: '#fff'},botMessage: {backgroundColor: '#f0f0f0',color: '#333'},}}customHeader={<divstyle={{padding: 12,backgroundColor: '#DCECDC'}}>Custom Header</div>}customFooter={<divstyle={{padding: 12,backgroundColor: '#F8F8F8'}}>Custom Footer</div>}messageStyle={(msg)=>({fontStyle: msg.sender==='bot' ? 'italic' : 'normal',})}inputProps={{maxLength: 200}}buttonProps={{disabled: false}}/>);}

🧩 Props

PropTypeDefaultDescription
onSendMessage(message: string) => voidundefinedCallback triggered when the user sends a message.
messagePlaceholderstring"Type a message..."Placeholder text for the input field.
chatButtonTextstring"💬"Text or emoji displayed on the floating toggle button.
openButtonTextstring"✖"Text shown to close the chat window.
headerTextstring"Chat"Text displayed in the chat header.
sendButtonTextstring"Send"Text inside the send message button.
botDefaultReplystring"This is a bot response."The default reply shown by the bot after the user sends a message.
stylesStyleProps{}Object for styling all internal parts of the component.
customHeaderReact.ReactNodeundefinedOptional custom header JSX/HTML to replace the default chat header.
customFooterReact.ReactNodeundefinedOptional custom footer JSX/HTML to replace the default input/footer.
messageStyle(msg: Message) => CSSPropertiesundefinedFunction to dynamically style each message.
inputPropsReact.InputHTMLAttributes<HTMLInputElement>{}Extra props for the <input> field.
buttonPropsReact.ButtonHTMLAttributes<HTMLButtonElement>{}Extra props for the send <button>.
containerStyleCSSProperties{}Style for the outermost container.

🎨 StyleProps Structure

interfaceStyleProps{container?: React.CSSProperties;header?: React.CSSProperties;body?: React.CSSProperties;messagesWrapper?: React.CSSProperties;inputWrapper?: React.CSSProperties;input?: React.CSSProperties;sendButton?: React.CSSProperties;userMessage?: React.CSSProperties;botMessage?: React.CSSProperties;toggleButton?: React.CSSProperties;title?: React.CSSProperties;}

📄 License

MIT © 2025 Stepan Dutchak

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages