This contact form lets users switch message intent inline using segmented controls, keeping the layout compact while improving message clarity.
HTML
<form class="contact-switch">
<div class="contact-switch__topics">
<button type="button" class="is-active">Support</button>
<button type="button">Sales</button>
</div>
<textarea placeholder="Write your message"></textarea>
<button type="submit">Send</button>
</form>CSS
.contact-switch {
width: 200px;
padding: 0.8rem;
border-radius: 18px;
background: linear-gradient(180deg, #ffffff, #f9fafb);
box-shadow: 0 18px 36px rgba(0,0,0,0.14);
display: grid;
gap: 0.45rem;
text-align: center;
}
.contact-switch__topics {
display: flex;
gap: 0.25rem;
background: #f3f4f6;
padding: 0.25rem;
border-radius: 999px;
}
.contact-switch__topics button {
flex: 1;
border: none;
background: transparent;
font-size: 11px;
color: #4b5563;
padding: 0.35rem 0;
border-radius: 999px;
cursor: pointer;
transition: background 150ms ease, color 150ms ease;
}
.contact-switch__topics button.is-active {
background: #ffffff;
color: #111827;
font-weight: 600;
}
.contact-switch textarea {
height: 50px;
resize: none;
padding: 0.45rem;
border-radius: 10px;
border: 1px solid #e5e7eb;
font-size: 12px;
color: #111827;
}
.contact-switch button[type="submit"] {
padding: 0.45rem;
border-radius: 999px;
border: none;
background: #6366f1;
color: #ffffff;
font-size: 12px;
cursor: pointer;
transition: transform 150ms ease;
}
.contact-switch button[type="submit"]:hover {
transform: translateY(-1px);
}
@media (prefers-color-scheme: dark) {
.contact-switch {
background: linear-gradient(180deg, #111827, #020617);
}
.contact-switch__topics {
background: #020617;
}
.contact-switch__topics button {
color: #9ca3af;
}
.contact-switch__topics button.is-active {
background: #111827;
color: #e5e7eb;
}
.contact-switch textarea {
background: #020617;
border-color: #374151;
color: #e5e7eb;
}
}Notes
- Topic selection without dropdowns
- Compact segmented-control pattern
- Ideal for SaaS widgets and dashboards
Preview styles shown. Production customization recommended.
Browse More UI Components
Explore hundreds of reusable HTML & CSS UI components built for modern web projects.
Discover buttons, cards, loaders, animations, layouts, and more all with live previews and clean, copy-paste code.
