HTML to Webflow examples

Pricing: monthly / yearly switch

A switch changes the prices of 2 plans from monthly to yearly.

  • JavaScript
  • Responsive
  • Hover states

What you receive in Webflow

  • 35 native elements and 19 classes.
  • Breakpoints: mobile landscape (767px).
  • States: hover.
  • 3 Embed elements keep the CSS or script that Webflow cannot express. To edit an Embed, you must have a paid Webflow site plan.

How to paste it

  1. Click Copy for Webflow.
  2. Open your page in the Webflow Designer.
  3. Press ⌘V or Ctrl+V.

HTML

<section class="pt">
  <div class="pt-inner">
    <h2 class="pt-title">Simple pricing that grows with you</h2>
    <div class="pt-switch-row">
      <span class="pt-period">Monthly</span>
      <label class="pt-switch"><input class="pt-check" type="checkbox" aria-label="Bill yearly"><span class="pt-knob"></span></label>
      <span class="pt-period">Yearly <span class="pt-save">Save 20%</span></span>
    </div>
    <div class="pt-plans">
      <div class="pt-plan">
        <h3 class="pt-name">Starter</h3>
        <p class="pt-desc">For freelancers and side projects.</p>
        <div class="pt-price"><span class="pt-amount" data-monthly="$12" data-yearly="$9">$12</span><span class="pt-per">/ month</span></div>
        <ul class="pt-list"><li class="pt-li">3 projects</li><li class="pt-li">10 GB storage</li><li class="pt-li">Email support</li></ul>
        <a href="#" class="pt-btn">Choose Starter</a>
      </div>
      <div class="pt-plan pt-plan-pro">
        <h3 class="pt-name">Pro</h3>
        <p class="pt-desc">For growing teams that ship every week.</p>
        <div class="pt-price"><span class="pt-amount" data-monthly="$39" data-yearly="$31">$39</span><span class="pt-per">/ month</span></div>
        <ul class="pt-list"><li class="pt-li">Unlimited projects</li><li class="pt-li">200 GB storage</li><li class="pt-li">Priority support</li><li class="pt-li">Team roles</li></ul>
        <a href="#" class="pt-btn pt-btn-pro">Choose Pro</a>
      </div>
    </div>
  </div>
</section>
<style>
.pt { font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; background: #ffffff; color: #111827; padding: 104px 24px; }
.pt-inner { max-width: 880px; margin: 0 auto; text-align: center; }
.pt-title { font-size: 44px; line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 28px; }
.pt-switch-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 48px; font-size: 15px; color: #4b5563; }
.pt-save { display: inline-block; margin-left: 6px; padding: 3px 8px; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 12px; font-weight: 700; }
.pt-switch { position: relative; display: inline-block; width: 52px; height: 30px; cursor: pointer; }
.pt-check { position: absolute; opacity: 0; width: 0; height: 0; }
.pt-knob { position: absolute; inset: 0; background: #d1d5db; border-radius: 999px; transition: background-color 0.25s ease; }
.pt-knob::before { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: #ffffff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.25s ease; }
.pt-check:checked + .pt-knob { background: #2563eb; }
.pt-check:checked + .pt-knob::before { transform: translateX(22px); }
.pt-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; text-align: left; }
.pt-plan { border: 1px solid #e5e7eb; border-radius: 20px; padding: 36px; display: flex; flex-direction: column; }
.pt-plan-pro { background: #111827; color: #f9fafb; border-color: #111827; }
.pt-name { font-size: 22px; margin: 0 0 6px; }
.pt-desc { font-size: 15px; line-height: 1.5; color: #6b7280; margin: 0 0 24px; }
.pt-plan-pro .pt-desc { color: #9ca3af; }
.pt-price { display: flex; align-items: baseline; gap: 6px; margin-bottom: 24px; }
.pt-amount { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; }
.pt-per { font-size: 15px; color: #6b7280; }
.pt-list { list-style: none; padding: 0; margin: 0 0 32px; flex-grow: 1; }
.pt-li { font-size: 15px; padding: 10px 0; border-top: 1px solid #f3f4f6; }
.pt-plan-pro .pt-li { border-top-color: #1f2937; }
.pt-btn { display: block; text-align: center; text-decoration: none; font-weight: 700; font-size: 15px; padding: 14px; border-radius: 12px; border: 1px solid #111827; color: #111827; transition: background-color 0.2s ease, color 0.2s ease; }
.pt-btn:hover { background: #111827; color: #ffffff; }
.pt-btn-pro { background: #2563eb; border-color: #2563eb; color: #ffffff; }
.pt-btn-pro:hover { background: #1d4ed8; border-color: #1d4ed8; }
@media (max-width: 767px) { .pt { padding: 72px 20px; } .pt-title { font-size: 32px; } .pt-plans { grid-template-columns: 1fr; } }
</style>
<script>
document.querySelectorAll(".pt").forEach(function (section) {
  var check = section.querySelector(".pt-check");
  check.addEventListener("change", function () {
    section.querySelectorAll(".pt-amount").forEach(function (el) {
      el.textContent = check.checked ? el.getAttribute("data-yearly") : el.getAttribute("data-monthly");
    });
  });
});
</script>