Overview
- Plus / minus buttons
- Min / max value limits
- Manual input support
- Input validation (numbers only)
- Lightweight and dependency-free
Basic usage
Use a wrapper with buttons and an input field inside.
HTML structure
<div class="quantity" data-anim-quantity>
<button
data-anim-quantity-minus
type="button"
></button>
<div class="quantity__input">
<input
data-anim-quantity-value
type="text"
value="1"
>
</div>
<button
data-anim-quantity-plus
type="button"
></button>
</div>
Attributes
-
data-anim-quantity— wrapper -
data-anim-quantity-value— input field -
data-anim-quantity-plus— increase value -
data-anim-quantity-minus— decrease value -
data-anim-quantity-min="1"— minimum value -
data-anim-quantity-max="10"— maximum value
Example with limits
Min / Max example
<input
data-anim-quantity-value
value="1"
data-anim-quantity-min="1"
data-anim-quantity-max="10"
>
Behavior
- Click "+" increases value
- Click "−" decreases value
- Value is limited by min / max
- Only numeric input is allowed
- Empty or invalid input resets to 1
Download
Use the Quantity component for product pages, forms, carts, and anywhere numeric input control is required.