<div data-slot='field'>
<label data-slot='field-label' for='quantity'>Quantity</label>
<div data-slot='number-field' role='group'>
<div data-slot='input-group-addon'>
<button
type='button'
data-slot='number-field-decrement'
tabindex='-1'
data-button
data-variant='ghost'
data-size='icon-xs'
aria-label='Decrease quantity'
>
<svg
class='icon'
data-slot='icon'
viewBox='0 0 24 24'
fill='none'
stroke='currentColor'
stroke-width='2'
stroke-linecap='round'
stroke-linejoin='round'
aria-hidden='true'
focusable='false'
>
<path d='M5 12h14'/>
</svg>
</button>
</div>
<input
data-slot='input'
id='quantity'
type='number'
inputmode='numeric'
name='quantity'
value='1'
min='1'
step='1'
>
<div data-slot='input-group-addon' data-align='inline-end'>
<button
type='button'
data-slot='number-field-increment'
tabindex='-1'
data-button
data-variant='ghost'
data-size='icon-xs'
aria-label='Increase quantity'
>
<svg
class='icon'
data-slot='icon'
viewBox='0 0 24 24'
fill='none'
stroke='currentColor'
stroke-width='2'
stroke-linecap='round'
stroke-linejoin='round'
aria-hidden='true'
focusable='false'
>
<path d='M5 12h14'/><path d='M12 5v14'/>
</svg>
</button>
</div>
</div>
</div>Installation
npx shadcn@latest add https://ui.full.dev/r/liquid/number-field.json https://ui.full.dev/r/liquid/field.json
Follow the one-time layout setup. A full components install already includes this item.
Usage
After this install, render these once in the layout head before theme overrides and other modules. The full ui hook already includes them. The command also installs the parts used in this example.
{% render 'ui-init' %}
{% render 'ui-input' %}
{% render 'ui-icon' %}
{% render 'ui-input-group' %}
{% render 'ui-button' %}
{% render 'ui-runtime' %}
{% render 'ui-number-field' %}
{% render 'ui-field' %}
The preview and its Usage tab render the same native Liquid source. Use data-slot for parts, data-variant for variants and data-size for sizes. Keep your store’s labels, translations and Shopify data in your theme.
A number field is an input group around a native <input type="number">, such as the quantity of a product or a cart line. The input keeps its own name, min, max and step, and works without JavaScript. The runtime connects the decrement and increment buttons: they step the input as its arrow keys do and fire input and change, so a cart script listens to the input only. The runtime also disables a button when a step would not change the value, at the input’s min or max, with step='any' or while the input is disabled or read-only, so set max to cap a quantity and disable the input to disable the field. It follows changed attributes and replaced markup; a script that sets the input’s value property fires input or change. The buttons take type='button', so Enter in the input still submits with the form’s own button, and tabindex='-1', as the input’s arrow keys step it. Each click steps once; holding a button does not repeat, as it does in React.
Parts
number-field, number-field-decrement, number-field-increment, with input-group-addon around the buttons and a native input.