EnInputStepper
Preview
Props
| Name | Description | Default | Control |
|---|---|---|---|
| wholeNumber | Prevents the value taking a decimal. boolean | false | |
| min | Lowest value the stepper will reach. Also where an empty value starts from on the first press. Null leaves the value unbounded below. number | null | |
| max | Highest value the stepper will reach. Null leaves the value unbounded above. number | null | |
| step | How far one press of + or − moves the value. number | 1 | |
| maxDecimal | Sets maximum number of decimal places for the return value. number | 2 | |
| disabled | Sets the disabled attribute on both buttons. boolean | null | |
| label | Names the value being adjusted, for the buttons' accessible labels — "Increase
monthly rate" rather than a bare "Increase". Needed when the buttons are the
only control for the value; when they sit beside a field that already carries
the label, pass string | null | |
| holdDelay | How long a button must be held before it starts repeating, in milliseconds. Zero turns press-and-hold off, leaving one step per press. number | 400 | |
| holdInterval | How often the value moves while a button is held, in milliseconds. number | 60 | |
| labelledByField | Marks the buttons as a convenience over a field holding the same value. They leave the tab order and are hidden from assistive tech, because the field beside them is the real control and would otherwise be announced twice. boolean | false |
Slots
No slots defined.
Events
change
No description
Methods
No methods defined.
Guidelines
EnInputStepper is the +/− pair on its own — it has no field, no label, no validation. It is a nudge control for a value some other input owns, for the rate and count fields where a user adjusts by a cent or a head rather than retyping the number.
It is not an EnInput* field in the usual sense: it doesn't participate in EnForm validation, takes no name or rules, and renders no error. Bind it to the same value as the field beside it.
Beside a field, or on its own
Almost always beside a field, in EnFormGroup's after slot. In that arrangement pass labelledByField: the buttons leave the tab order and are hidden from assistive tech, because the field is the real control and would otherwise be announced twice.
When the buttons are the only control for the value, drop labelledByField and pass label instead. They then stay focusable and name themselves "Increase seats" rather than a bare "Increase".
Bind it to the unformatted value
parseFloat stops at the first character it can't read, so "1,489.08" reads as 1 and "$412.00" as NaN — stepping either would write a wildly wrong number back. The stepper refuses to step a formatted value and warns once in the console.
The En inputs already keep their formatting to the display and hand their model a plain number, so binding both to the same model is correct. The trap is a hand-rolled field that puts a formatted string in the model.
Dos
- Set
minon any value with a floor. An empty field lands onminon the first press — so a "max children: 1–5" field gives 1, not 0. - Match
stepto the unit the value moves in:0.01for a rate,1for a count,5for an age band. - Use
wholeNumberfor counts, so the value can't pick up a decimal from elsewhere.
Don'ts
- Don't use a stepper for a value with a wide range. Nudging from 0 to 4,000 is not a nudge — that's a field.
- Don't give it both
labelandlabelledByField; the label is ignored when the buttons are hidden from assistive tech.
Press and hold
Holding a button repeats the step — holdDelay before it starts (0 turns it off), then one step every holdInterval. Repeating stops on release, on leaving the button, and on hitting min/max.
Examples
Beside a field, in the after slot
A bounded whole number
min and max disable the button that can no longer move.
Standing alone
No field, so the buttons name themselves from label and stay in the tab order.
In a rate grid
The pattern it was built for — a narrow field and its stepper per row, held on one line by btn-container-nowrap.