This checkout form lets users switch payment methods inline using a segmented control, reducing friction and avoiding separate selection screens in compact checkout flows.
HTML
<form class="checkout-method">
<div class="checkout-method__switch">
<button type="button" class="is-active">Card</button>
<button type="button">Wallet</button>
</div>
<input type="text" placeholder="Card number" />
<button type="submit">Complete Payment</button>
</form>CSS
.checkout-method {
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;
}
.checkout-method__switch {
display: flex;
gap: 0.25rem;
padding: 0.25rem;
border-radius: 999px;
background: #f3f4f6;
}
.checkout-method__switch button {
flex: 1;
border: none;
background: transparent;
font-size: 11px;
padding: 0.35rem 0;
border-radius: 999px;
color: #4b5563;
cursor: pointer;
transition: background 150ms ease, color 150ms ease;
}
.checkout-method__switch button.is-active {
background: #ffffff;
color: #111827;
font-weight: 600;
}
.checkout-method input {
padding: 0.45rem;
border-radius: 10px;
border: 1px solid #e5e7eb;
font-size: 12px;
color: #111827;
}
.checkout-method button[type="submit"] {
padding: 0.45rem;
border-radius: 999px;
border: none;
background: #6366f1;
color: #ffffff;
font-size: 12px;
cursor: pointer;
transition: transform 150ms ease;
}
.checkout-method button[type="submit"]:hover {
transform: translateY(-1px);
}
@media (prefers-color-scheme: dark) {
.checkout-method {
background: linear-gradient(180deg, #111827, #020617);
}
.checkout-method__switch {
background: #020617;
}
.checkout-method__switch button {
color: #9ca3af;
}
.checkout-method__switch button.is-active {
background: #111827;
color: #e5e7eb;
}
.checkout-method input {
background: #020617;
border-color: #374151;
color: #e5e7eb;
}
}Notes
- Inline method switching without dropdowns
- Reduces checkout interruption
- Scales to additional payment types
- Ideal for SaaS upgrades and add-ons
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.
