Quantity
The quantity stepper for product pages and carts: decrease, the number and increase, from 1 up to the stock left.
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
PreviewCode
EnglishMirroredArabic
LTR →
Installation
Add the component
npx ritla add quantityAlso works with shadcn:
npx shadcn@latest add @ritla/quantityDependencies it brings
buttonOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { Quantity } from "@/components/ui/quantity";<Quantity value={quantity} onValueChange={setQuantity} max={stock} />API reference
Quantity
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue / onValueChange | number | 1 | The number. |
min | number | 1 | The lowest number. A cart line is removed with its remove button, never by stepping to 0. |
max | number | None | The stock left. |
size | "md" | "sm" | "md" | Figma's Size: 40px steppers for the product page, 32px for carts. |
label | string | None | The field's name. In a cart, add the product (“Quantity, Lina chair”). |
decrementLabel / incrementLabel | string | None | The steppers' names. Default “Decrease quantity” and “Increase quantity”. |
name / disabled | … | None | As on Number Input. |
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| ArrowUpArrowDown | Steps up and down by one. |
| Tab | Decrease, then the field, then increase. |
ARIA
- The field is a
spinbuttonbetween two named buttons; each button disables at the minimum or maximum. - The buttons are drawn at 40 and 32px, with a 48px touch area in height only, so it never covers the number.
Arabic and RTL notes
Mirrors
- Decrease sits at the start, on the right, and increase on the left.
Does not mirror
- The − and + glyphs and the number never mirror.
- Numerals
- The number uses the page numerals and accepts Arabic-Indic digits when typed.
- Arabic typography
label-16Medium at md,label-14Medium at sm.