NEWVersion 1.0 is here.
OpenTailwindv1.0
BlocksTemplatesCollectionsGuidesPricing
How to Build a Pricing Page with Tailwind CSS (Monthly/Yearly Toggle)
BlogHow to Build a Pricing Page with Tailwind CSS (Monthly/Yearly Toggle)
TutorialApril 7, 2026·8 min read

How to Build a Pricing Page with Tailwind CSS (Monthly/Yearly Toggle)

Build a responsive pricing page with a working monthly/yearly toggle using only Tailwind CSS and vanilla JavaScript. Includes accessibility and dark mode support.

By OpenTailwind, by lindo.ai

On this page

  1. The Structure
  2. Step 1: The Toggle
  3. Step 2: Pricing Cards
  4. Step 3: The Toggle JavaScript
  5. More Pricing Layouts

Every SaaS product needs a pricing page. Here's how to build one with Tailwind CSS that includes a working monthly/yearly toggle, responsive cards, and proper dark mode support.

The Structure

A good pricing page has three parts: a header (title + toggle), pricing cards (2-3 plans), and a feature comparison (optional). Let's build each.

Step 1: The Toggle

Monthly/yearly pricing toggle with a "Save 20%" badge on yearly.

<div class="flex items-center justify-center gap-3">
  <span class="text-sm text-neutral-600 dark:text-neutral-400">Monthly</span>
  <button id="pricing-toggle" type="button" role="switch" aria-checked="false"
    class="relative w-12 h-6 bg-neutral-200 dark:bg-neutral-700 rounded-full transition-colors">
    <span class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform"></span>
  </button>
  <span class="text-sm text-neutral-600 dark:text-neutral-400">Yearly</span>
  <span class="text-xs bg-emerald-100 dark:bg-emerald-900/40 text-emerald-700 dark:text-emerald-300 px-2 py-0.5 rounded-full">Save 20%</span>
</div>

Step 2: Pricing Cards

Three cards — Free, Pro (highlighted), and Enterprise. The highlighted card uses your accent color.

Pricing cards with toggle — from OpenTailwind
Pricing cards with toggle — from OpenTailwind — View & copy code

Key design decisions:

  • Highlight the recommended plan with a colored border or background
  • Show the price prominently with the billing period below
  • List 4-6 features per plan — enough to differentiate, not enough to overwhelm
  • Use checkmarks for included features, dashes or X marks for excluded

Step 3: The Toggle JavaScript

const toggle = document.getElementById('pricing-toggle');
const monthlyPrices = document.querySelectorAll('[data-price="monthly"]');
const yearlyPrices = document.querySelectorAll('[data-price="yearly"]');

toggle.addEventListener('click', () => {
  const isYearly = toggle.getAttribute('aria-checked') === 'true';
  toggle.setAttribute('aria-checked', !isYearly);

  // Toggle visual state
  toggle.querySelector('span').style.transform =
    !isYearly ? 'translateX(24px)' : 'translateX(0)';
  toggle.style.backgroundColor =
    !isYearly ? 'rgb(99 102 241)' : ''; // indigo-500

  // Toggle prices
  monthlyPrices.forEach(el => el.classList.toggle('hidden', !isYearly));
  yearlyPrices.forEach(el => el.classList.toggle('hidden', isYearly));
});

More Pricing Layouts

Not every product fits the 3-card layout. Here are alternatives:

Single highlighted plan — great for simple products
Single highlighted plan — great for simple products — View & copy code
Four-column pricing for products with many tiers
Four-column pricing for products with many tiers — View & copy code

💡 Pro tip: Always show the yearly price as a monthly equivalent (e.g., '$8/mo billed annually') — it looks cheaper and converts better than showing the full annual price.

All pricing blocks shown here are available on OpenTailwind with full dark mode support and working toggles.

Library access: Tutorials and their educational demos are public. Copying library designs requires an account: 100 selected blocks and five templates per industry are free. Pro lifetime access unlocks the complete library.

Keep building

Tailwind CSS Table: Responsive, Striped and Sticky Examples ↗

Style HTML tables with Tailwind CSS: responsive horizontal scroll, striped rows, sticky headers, dark mode, number alignment and stacked mobile rows, with a live demo.

Tailwind CSS Grid: A Practical Layout Guide for v4 ↗

Learn Tailwind CSS grid in v4: columns, spans, auto-fit responsive grids, bento layouts, subgrid and container queries, with copy-paste HTML examples.

Browse 1,761 Tailwind CSS blocks

100 free blocks, five free templates per industry, and Pro lifetime access to the complete block and template library.

Browse BlocksTemplates
← Previous article

How to Add Dark Mode to Any Tailwind CSS Website (The Right Way)

Next article →

Responsive Tailwind CSS Navbar: Working Menu and 5 Layouts

OpenTailwindv1.0

A little less starting from scratch.
A lot more making it yours.

Made with care by lindo.ai

The library

All blocksAll templatesHero sectionsPricing sections

Around here

Our storyGuides & ideasDesign examplesMembership & pricingQuestions?

Good design is a
good place to start.

FREE TO EXPLORE. YOURS TO BUILD.
© 2026 OpenTailwind · by lindo.ai
TermsPrivacyCookies All creativity welcome