Quantity Stepper

Plus/minus tailwind quantity selector for carts and product pages.

Tailwind CSS
<div class="inline-flex items-center rounded-xl border border-slate-300 overflow-hidden">
  <button type="button" aria-label="Decrease quantity" class="px-3 py-2 text-slate-500 dark:text-slate-400 hover:bg-slate-200 hover:text-slate-800 transition-colors text-lg font-bold leading-none">-</button>
  <input type="text" value="1" aria-label="Quantity" class="w-10 text-center text-sm font-semibold border-x border-slate-300 py-2 focus:outline-none" />
  <button type="button" aria-label="Increase quantity" class="px-3 py-2 text-slate-500 dark:text-slate-400 hover:bg-slate-200 hover:text-slate-800 transition-colors text-lg font-bold leading-none">+</button>
</div>

Free to use in personal and commercial projects. No attribution required.

Variants

Same component, different looks. Preview each one live and copy the code you like.

Pill

Fully rounded shape that suits playful shops and food apps.

Tailwind CSS

Dark

For dark carts and checkout pages.

Tailwind CSS

Separated

Detached buttons with gaps for airy modern product pages.

Tailwind CSS

About this quantity stepper

A tailwind quantity selector is the plus/minus control shoppers use on product pages and in carts, and getting its details right matters for conversion: it must be tappable on phones, readable at a glance, and impossible to break with bad input. The quantity input plus minus buttons pattern beats a raw number field because it guides the user and prevents negative or absurd values.

This product quantity stepper is an inline-flex pill with three segments: a minus button, a centered value, and a plus button, divided by hairline borders. The overflow-hidden wrapper keeps the rounded corners clean where the segments meet. Bold, large minus and plus glyphs give generous touch targets, and the center input stays narrow so the whole control fits beside an add-to-cart button.

Use it anywhere a count is chosen: product pages, cart line items, ticket pickers. Clamp the value in your handler (minimum 1, maximum stock) and disable the minus button at the floor. On mobile, keep the whole stepper at least 44px tall so thumbs hit it comfortably.

A raw number field on a product page is an invitation for garbage: negative quantities, zeroes, or 9999 typed as a joke. Each bad value needs validation, an error message, and a frustrated shopper. The stepper constrains choice to sane values with zero typing required. On phones it is even better, since tapping plus beats switching to the numeric keyboard and back.

Three segments sit in an inline-flex pill: minus button, centered value, plus button, divided by hairline borders. The wrapper uses overflow-hidden so the outer rounding stays clean where the segments meet. The center input stays narrow with centered text, keeping the whole control compact enough to sit beside an add-to-cart button. Bold, large glyphs give each button a generous touch target.

Clamp the value in the handler with a minimum of 1 and a maximum of available stock, and disable the minus button visually at the floor. Let shoppers type directly into the middle input for larger counts, validating on blur. When stock runs low, show a hint like Only 3 left near the stepper; scarcity plus the max clamp work together. On mobile, keep the whole control at least 44px tall.

The desync bug: the typed input accepts a value the buttons would never allow. A shopper types 99 into the middle field, the display shows 99, but stock is 5 and the cart total computes for 99. Always clamp on blur and on submit, not just on button clicks. The buttons and the input must obey the same limits, or the number on screen is a lie.

Where to use it

  • ✓ E-commerce product pages
  • ✓ Cart quantity selector for checkout flows
  • ✓ Ticket and booking pickers
  • ✓ Food ordering item counts

Customization tips

Round it fully with rounded-full for a softer look, or square it off to match sharp branding. Swap the text glyphs for minus/plus SVG icons at small sizes. Style the disabled minus state with opacity-40 and cursor-not-allowed when quantity hits 1.

Design notes

When to use

Quantity steppers belong on product pages and cart line items, where shoppers adjust counts in small ranges like one to nine. The plus and minus buttons are faster than typing for these small changes and work well on touch screens. They shine when the minimum and maximum are enforced clearly, like a two ticket limit.

What to avoid

Do not use a stepper for large quantities, because tapping plus forty times for forty items is absurd, so offer direct input for bulk orders. Avoid allowing negative or zero quantities through sloppy validation. And do not hide the stepper behind a hover state on desktop, since touch users will never find it.

Accessibility

Label the buttons Decrease quantity and Increase quantity, and announce the new value through a live region so screen reader users hear the result. Keep both buttons keyboard operable and mark the minus as disabled at the minimum with aria-disabled.

Frequently asked questions

How do I make a tailwind quantity selector with working plus minus buttons?

Use three segments in an inline-flex container: two buttons and a center input. Each button click parses the current value, adds or subtracts one, clamps it between 1 and your max, and writes it back. Keep the value in a single variable so manual typing and button clicks stay in sync.

Should the middle be an input or plain text?

An input is friendlier: shoppers can type '12' instead of tapping plus eleven times. Validate on blur, strip non-digits, and fall back to the last valid value if the field is emptied.

How do I stop users from entering negative quantities?

Clamp in the handler with Math.max(1, value) and also set min='1' on the input. Disable the minus button visually when the value is 1 so users get the hint before clicking.

How do I hide the native number input arrows in CSS?

Set appearance: textfield on the input and target the WebKit pseudo-elements with input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }. Firefox needs the appearance property while Chrome and Safari need the pseudo-element reset. Do this whenever you provide custom plus and minus buttons, so you never get double controls.

How do I make quantity stepper buttons accessible?

Give each button a specific aria-label like "Increase quantity" and "Decrease quantity", since a bare plus or minus glyph has no accessible name. Keep the input itself labeled with aria-label="Quantity" or a visible label. Native arrow-key support comes free if you keep the input as type="number".

How do I sync a quantity stepper with the cart total?

After changing the value in JavaScript, dispatch an input or change event, or call your cart update function directly. Read the min, max, and step attributes so the buttons respect product limits instead of hardcoding them. Forgetting the event dispatch is the most common reason totals fail to update.

Customize it with our tools