Skip to content

Usage-Based Pricing Slider

Tailwind CSS pricing card with a range slider that updates the plan, monthly price and cost per 1,000 requests as usage changes.

Tailwind CSS Pricing Tables Responsive Dark #card #pricing #range #saas #slider

Live preview

Open in new tab

Code

A usage-based pricing card built with Tailwind CSS and a few lines of vanilla JavaScript: visitors drag a slider to pick their monthly API request volume and immediately see the plan name, the monthly price and the cost per 1,000 requests. It suits APIs, email services, hosting and other SaaS products billed by consumption.

How it works

The root is section.ups-pricing. All pricing data lives in data attributes on that element: data-ups-volumes lists the volume steps, data-ups-prices the matching monthly prices and data-ups-plans the plan name for each step. The card is a grid that splits into a dark slider panel and a lime feature panel from the md breakpoint; on phones the panels stack.

The slider is a native input type="range" with the class .ups-range. Its value is an index into the lists, so the steps can be unevenly spaced while the thumb moves in equal steps. On every input event the script reads the index, updates the output element marked data-ups-volume, the data-ups-plan badge, the data-ups-price amount and the data-ups-rate line, and changes the data-ups-cta button text. A price that is not a number, such as custom on the last step, switches the card to a "Custom / Talk to sales" state.

style.css styles the range track with a gradient whose stop is the --ups-fill custom property; the script sets it to the slider position so the filled part follows the thumb. Without JavaScript the markup still shows a correct 100,000 request price.

Customization

  • data-ups-volumes and data-ups-prices on .ups-pricing: replace with your own tiers; keep both lists the same length. The script sets the slider max automatically.
  • data-ups-plans: rename the tiers shown in the badge, e.g. Free,Pro,Team.
  • data-ups-unit: change "requests" to "emails", "GB" or "seats" in the rate line and screen reader text.
  • value="3" on #ups-range: choose the step that is selected on page load (also update the static text and the --ups-fill default in style.css).
  • --ups-accent and --ups-track in .ups-range: recolor the filled and empty parts of the track and the thumb ring.
  • bg-lime-400 on the feature panel: swap for another Tailwind color to change the brand accent.
  • The tick labels use left-[37.5%] and left-[75%]; move them to match the index positions of your own steps.

Accessibility

The slider is a real range input with a visible label, so arrow keys, Page Up/Down, Home and End all work. The script keeps aria-valuetext in sync, so screen readers hear "250,000 requests per month, $79 per month" instead of a bare index. A sr-only region with aria-live="polite" announces the selected plan after a short debounce. The thumb gets a stronger glow on :focus-visible, the CTA has a focus ring, decorative check icons are aria-hidden and thumb transitions are disabled under prefers-reduced-motion.

Usage notes

Requires the Tailwind browser build (added automatically). Several cards can share a page because each .ups-pricing is initialized separately; give every copy a unique id for the range and its label.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Usage-Based Pricing Slider – Tailwind CSS pricing tables component screenshot
Usage-Based Pricing Slider · Tailwind CSS Pricing Tables

More Pricing Tables

Pricing Cards with Hover – Pure CSS pricing tables preview

Pricing Cards with Hover

Three pure CSS pricing cards with hover lift and a featured plan that has a spinning conic-gradient border, glow and Most popular badge.

Pricing Cards with Billing Toggle – Bootstrap 5 pricing tables preview

Pricing Cards with Billing Toggle

Bootstrap 5 pricing cards with a Monthly / Annual segmented switch that updates prices, savings and yearly totals, plus a highlighted featured plan.

Pricing Comparison Table – Bootstrap 5 pricing tables preview

Pricing Comparison Table

Dark Bootstrap 5 plan comparison table with grouped features, highlighted popular plan, sticky feature column, tooltips and a show-only-differences switch.