A wrapper element that augments a <input type="number">
with increment/decrement
controls.
Import and register the <number-control>
custom element, upgrading any
<number-control>
elements already in the DOM:
import NumberControl from 'literal/documentation/templates/number-control.js';
The <number-control>
element wraps an <input type="number">
, augmenting it
with styleable decrement/increment buttons and up/down arrow keyboard behaviour:
<number-control>
<input type="number" />
</number-control>
Default content of decrement and increment buttons may be overridden with custom HTML:
<number-control>
<span slot="decrement-button">☚</span>
<span slot="increment-button">☛</span>
<input type="number" min="-1" max="1" step="0.1" />
</number-control>
Note that the element itself is not a form element. It has no value
and does
not set any form data in its internals.
::part(decrement-button)
::part(increment-button)
--button-width
.5rem; Width of decrement/increment buttons.
slot="decrement-button"
Replace default content of the decrement button ("-"
) with custom HTML.
slot="increment-button"
Replace default content of the increment button ("+"
) with custom HTML.
Support development: Sponsor
github.com/stephband/form-elements
github.com/stephband/form-elements/issues
Built by Stephen Band for Cruncher.
Documentation set in Euclid
and Martian Mono. Fonts
used for documentation not included as part of the license covering the
use of number-control
.