About this snippet

Let users estimate costs with this dynamic pricing slider. Dragging the handle updates the price and feature limits in real-time, which is perfect for SaaS products with variable usage tiers.

Size
2.1 KB
Uses
HTML, CSS, JavaScript
Loads
Nothing external
Views
284
<div class="pricing-card">
  <div class="header">
    <h3>Pro Plan</h3>
    <div class="price">$<span id="priceVal">29</span>/mo</div>
  </div>
  <div class="range-area">
    <input type="range" min="1" max="5" value="2" class="slider" id="priceRange">
    <div class="users-label"><span id="userCount">5</span> Users</div>
  </div>
  <ul class="features">
    <li>&#10003; Full Access</li>
    <li>&#10003; Priority Support</li>
    <li>&#10003; 100GB Storage</li>
  </ul>
  <button>Choose Plan</button>
</div>
.pricing-card {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  background: #fff;
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  max-width: 320px;
  margin: 0 auto;
  text-align: center;
}
.header h3 {
  margin: 0;
  color: #6b7280;
  font-size: 1rem;
}
.price {
  font-size: 3rem;
  font-weight: 800;
  color: #1f2937;
  margin: 10px 0;
}
.range-area {
  margin: 30px 0;
}
.slider {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  background: #e5e7eb;
  border-radius: 5px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background: #2563eb;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 4px #dbeafe;
}
.users-label {
  margin-top: 10px;
  color: #3b82f6;
  font-weight: 600;
}
.features {
  list-style: none;
  padding: 0;
  color: #4b5563;
  margin-bottom: 30px;
  line-height: 2;
}
button {
  width: 100%;
  padding: 12px;
  background: #111827;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
const range = document.getElementById("priceRange");
const price = document.getElementById("priceVal");
const users = document.getElementById("userCount");

const plans = [
  { users: 1, price: 9 },
  { users: 5, price: 29 },
  { users: 10, price: 49 },
  { users: 25, price: 99 },
  { users: 100, price: 199 }
];

range.addEventListener("input", function() {
  const index = this.value - 1;
  const plan = plans[index];
  
  price.innerText = plan.price;
  users.innerText = plan.users;
});
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save