Number Selector
A number selector allows the user to add or remove quantities incrementally.
When to Use
- Use a number selector when users are most likely to increase or decrease a value by a small range of increments. For example, when adding passengers to a travel booking.
When Not to Use
- If the user is selecting from a larger range of values consider a Select or Text Input Field instead.
Developer Notes
A number selector is a simple combination of two buttons and a number <input>
element. The button to decrement the number should have a class of .spark-number-selector__down
. Similarly, the button to increment the number should have a class of .spark-number-selector__up
.
Use of the number selector requires a JavaScript helper. It can be instantiated using new Spark.NumberSelector(el)
or $(el).sparkNumberSelector()
. You may programmatically call the value
method to get or set the value of the input, as well as use the increment
and decrement
methods to step the value up or down.