ChatBox Form

The chatbox html form is a form template that can be used to create a form for a chatbox popup like contact form.

Preview
Chat Box Form
<div class="main-wrapper">
<div class="w-full">
<div class="form-wrapper">
<div class="form-header">
<h3>Let's chat? - Online</h3>
<button>
<svg width="17" height="17" viewBox="0 0 17 17" fill="white">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M0.474874 0.474874C1.10804 -0.158291 2.1346 -0.158291 2.76777 0.474874L16.5251 14.2322C17.1583 14.8654 17.1583 15.892 16.5251 16.5251C15.892 17.1583 14.8654 17.1583 14.2322 16.5251L0.474874 2.76777C-0.158291 2.1346 -0.158291 1.10804 0.474874 0.474874Z"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M0.474874 16.5251C-0.158291 15.892 -0.158291 14.8654 0.474874 14.2322L14.2322 0.474874C14.8654 -0.158292 15.892 -0.158291 16.5251 0.474874C17.1583 1.10804 17.1583 2.1346 16.5251 2.76777L2.76777 16.5251C2.1346 17.1583 1.10804 17.1583 0.474874 16.5251Z"
/>
</svg>
</button>
</div>
<form class="chatbox-form">
<div class="mb-5">
<label for="name" class="form-label"> Your Name </label>
<input
type="text"
name="name"
id="name"
placeholder="Your Name"
class="form-input"
/>
</div>
<div class="mb-5">
<label for="email" class="form-label"> Email Address </label>
<input
type="email"
name="email"
id="email"
placeholder="[email protected]"
class="form-input"
/>
</div>
<div class="mb-5">
<label for="message" class="form-label"> Message </label>
<textarea
rows="6"
name="message"
id="message"
placeholder="Explain you queries"
class="form-input"
></textarea>
</div>
<div>
<button class="btn w-full">Submit</button>
</div>
</form>
</div>
<div class="action-buttons">
<button class="action-btn" onclick="closeChatbox()">
<svg
width="17"
height="17"
viewBox="0 0 17 17"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M0.474874 0.474874C1.10804 -0.158291 2.1346 -0.158291 2.76777 0.474874L16.5251 14.2322C17.1583 14.8654 17.1583 15.892 16.5251 16.5251C15.892 17.1583 14.8654 17.1583 14.2322 16.5251L0.474874 2.76777C-0.158291 2.1346 -0.158291 1.10804 0.474874 0.474874Z"
fill="white"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M0.474874 16.5251C-0.158291 15.892 -0.158291 14.8654 0.474874 14.2322L14.2322 0.474874C14.8654 -0.158292 15.892 -0.158291 16.5251 0.474874C17.1583 1.10804 17.1583 2.1346 16.5251 2.76777L2.76777 16.5251C2.1346 17.1583 1.10804 17.1583 0.474874 16.5251Z"
fill="white"
/>
</svg>
</button>
<button class="action-btn" onclick="openChatbox()">
<svg
width="28"
height="28"
viewBox="0 0 28 28"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19.8333 14.0002V3.50016C19.8333 3.19074 19.7103 2.894 19.4915 2.6752C19.2728 2.45641 18.976 2.3335 18.6666 2.3335H3.49992C3.1905 2.3335 2.89375 2.45641 2.67496 2.6752C2.45617 2.894 2.33325 3.19074 2.33325 3.50016V19.8335L6.99992 15.1668H18.6666C18.976 15.1668 19.2728 15.0439 19.4915 14.8251C19.7103 14.6063 19.8333 14.3096 19.8333 14.0002ZM24.4999 7.00016H22.1666V17.5002H6.99992V19.8335C6.99992 20.1429 7.12284 20.4397 7.34163 20.6585C7.56042 20.8772 7.85717 21.0002 8.16659 21.0002H20.9999L25.6666 25.6668V8.16683C25.6666 7.85741 25.5437 7.56066 25.3249 7.34187C25.1061 7.12308 24.8093 7.00016 24.4999 7.00016Z"
fill="white"
/>
</svg>
</button>
</div>
</div>
</div>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Inter", sans-serif;
}
.mb-5 {
margin-bottom: 20px;
}
.pt-3 {
padding-top: 12px;
}
.main-wrapper {
display: flex;
align-items: center;
justify-content: center;
padding: 48px;
}
.form-wrapper {
margin: 0 auto;
max-width: 550px;
width: 100%;
background: white;
border: 1px solid #e0e0e0;
border-radius: 8px;
}
.form-wrapper.active {
display: block;
}
.form-label {
display: block;
font-weight: 500;
font-size: 16px;
color: #07074d;
margin-bottom: 12px;
}
.form-label-2 {
font-weight: 600;
font-size: 20px;
margin-bottom: 20px;
}
.form-input {
width: 100%;
padding: 12px 24px;
border-radius: 6px;
border: 1px solid #e0e0e0;
background: white;
font-weight: 500;
font-size: 16px;
color: #6b7280;
outline: none;
resize: none;
}
.form-input:focus {
border-color: #6a64f1;
box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.05);
}
.btn {
text-align: center;
font-size: 16px;
border-radius: 6px;
padding: 14px 32px;
border: none;
font-weight: 600;
background-color: #6a64f1;
color: white;
cursor: pointer;
}
.btn:hover {
box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.05);
}
.-mx-3 {
margin-left: -12px;
margin-right: -12px;
}
.px-3 {
padding-left: 12px;
padding-right: 12px;
}
.flex {
display: flex;
}
.flex-wrap {
flex-wrap: wrap;
}
.w-full {
width: 100%;
}
.form-header {
background: #6a64f1;
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 36px;
border-radius: 8px 8px 0px 0px;
}
.form-header h3 {
font-weight: 700;
font-size: 20px;
color: white;
}
.form-header button {
color: white;
background: transparent;
border: none;
}
.chatbox-form {
padding: 32px 36px;
}
.action-buttons {
max-width: 550px;
margin-left: auto;
margin-right: auto;
display: flex;
align-items: center;
justify-content: flex-end;
margin-top: 48px;
}
.action-btn {
width: 70px;
height: 70px;
background: #6a64f1;
color: white;
border-radius: 50%;
margin-left: 20px;
border: none;
cursor: pointer;
}
@media (min-width: 540px) {
.sm\:w-half {
width: 50%;
}
}
</style>
<script>
const formWrapper = document.querySelector(".form-wrapper");
const openChatbox = () => {
formWrapper.classList.toggle("active");
};
const closeChatbox = () => {
formWrapper.classList.remove("active");
};
</script>