Skip to content

Quantity

Beta
Get Ritla UI

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

  1. Add the component

    npx ritla add quantity

    Also works with shadcn: npx shadcn@latest add @ritla/quantity

  2. Dependencies it brings

    button

  3. Or 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

quantity.tsx
import { Quantity } from "@/components/ui/quantity";<Quantity value={quantity} onValueChange={setQuantity} max={stock} />

API reference

Quantity

PropTypeDefaultDescription
value / defaultValue / onValueChangenumber1The number.
minnumber1The lowest number. A cart line is removed with its remove button, never by stepping to 0.
maxnumberNoneThe stock left.
size"md" | "sm""md"Figma's Size: 40px steppers for the product page, 32px for carts.
labelstringNoneThe field's name. In a cart, add the product (“Quantity, Lina chair”).
decrementLabel / incrementLabelstringNoneThe steppers' names. Default “Decrease quantity” and “Increase quantity”.
name / disabled…NoneAs 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.

KeyAction
ArrowUpArrowDownSteps up and down by one.
TabDecrease, then the field, then increase.

ARIA

  • The field is a spinbutton between 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-16 Medium at md, label-14 Medium at sm.