Cart Quantity
React Native (Expo)
A React Native quantity picker whose minus turns into a bin at one so the same tap removes the item.
A quantity picker for a cart line. At one, the minus becomes a bin so the same tap removes the item instead of going to zero. The number pops when it changes and the plus dims at the limit. Each button names the item it changes, and the new quantity is announced. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add cart-quantityManual
- Copy the code from the component tab.
- Create a file at
components/ui/cart-quantity.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | - | The current quantity. |
onChange | (value: number) => void | - | Called with the new quantity. |
onRemove | () => void | - | Called when minus is pressed at 1; the minus then shows a bin. |
max | number | 99 | The most that can be ordered. |
label | string | "item" | Spoken name of the item. |
colors | Partial<CartQuantityColors> | - | Overrides surface, border, text, accent and remove. |
style | StyleProp<ViewStyle> | - | Style for the picker. |
Comments