Skip to content

Incrementer

Use Incrementer to let shoppers increase or decrease a numeric value, such as a cart quantity. It enforces min and max, shows a validation message when the value is out of range, and can hide its buttons for a compact layout.

The SDK Incrementer showing a numeric value with increase and decrease buttons.
import { Incrementer } from '/@dropins/tools/components.js';
PropTypeReq?Description
namestringNoField name, used to map the value in a form.
size'medium' | 'large'NoChange the incrementer size. Defaults to medium.
minnumberNoMinimum allowed value.
maxnumberNoMaximum allowed value.
showButtonsbooleanNoShow the increase and decrease buttons. Defaults to true.
disabledbooleanNoWhether the field is disabled. Defaults to false.
errorbooleanNoWhether the field shows an error state.
successbooleanNoWhether the field value updated successfully.
maxLengthnumberNoMaximum length of the input field.
onValue(value: any) => voidNoCallback to handle value changes.
onUpdateError(error: Error) => voidNoCallback to handle errors thrown by onValue.

Incrementer also accepts standard input HTML attributes (for example, value, which defaults to 1, and aria-label), except size.

Render a quantity incrementer bounded between 1 and 100:

import { Incrementer, provider } from '/@dropins/tools/components.js';
await provider.render(Incrementer, {
name: 'quantity',
value: '1',
min: 1,
max: 100,
'aria-label': 'Quantity',
onValue: (value) => yourUpdateQuantity(value),
})(document.querySelector('.incrementer'));
  • Field — wrap the Incrementer with a label and helper text.
  • Button — pair with an add-to-cart action.