DEV Community

Je Phiri
Je Phiri

Posted on

1

Floating button for chat app in HTML, JavaScript and CSS

If you're looking to add a floating button for chat apps, you can achieve this using HTML, CSS, and JavaScript. Here's a simple example:

HTML
html
Copy
Edit
<!DOCTYPE html>




Floating Chat Button


<!-- Floating Chat Button -->
<div class="chat-button" id="chatButton">

</div>

<script src="script.js"></script>



CSS (styles.css)
css
Copy
Edit
.chat-button {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #007bff;
color: white;
width: 60px;
height: 60px;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
cursor: pointer;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
transition: background 0.3s, transform 0.2s;
}

.chat-button:hover {
background-color: #0056b3;
transform: scale(1.1);
}
JavaScript (script.js)
js
Copy
Edit
document.getElementById('chatButton').addEventListener('click', function() {
alert('Chat button clicked! You can integrate this with a chat service.');
});
This code creates a simple floating chat button that you can integrate with a chat application like WhatsApp, Messenger, or a custom chatbot.
This floating chat app button appears at the bottom right of the screen and toggles a simple chat box when clicked.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (1)

Collapse
 
kelvincode1234 profile image
Precious Kelvin Nwaogu • Edited

Image description

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

👋 Kindness is contagious

Dive into this informative piece, backed by our vibrant DEV Community

Whether you’re a novice or a pro, your perspective enriches our collective insight.

A simple “thank you” can lift someone’s spirits—share your gratitude in the comments!

On DEV, the power of shared knowledge paves a smoother path and tightens our community ties. Found value here? A quick thanks to the author makes a big impact.

Okay