InputStepper

Enables incremental changes of a counter within a form.

To implement InputStepper component into your project you’ll need to add the import:

import InputStepper from "@kiwicom/orbit-components/lib/InputStepper";

After adding import into your project you can use it simply like:

<InputStepper />

Table below contains all types of the props available in InputStepper component.

NameTypeDefaultDescription
defaultValuenumber0Specifies the value of the InputStepper. See Functional specs
disabledbooleanfalseIf true, the InputStepper will be disabled.
errorReact.NodeThe error to display beneath the InputStepper. See Functional specs
helpReact.NodeThe help to display beneath the InputStepper.
labelTranslationThe label for the InputStepper. See Functional specs
maxValuenumberSpecifies the maximum value for the InputStepper.
minValuenumber-∞Specifies the minimum value for the InputStepper.
namestringThe name for the InputStepper.
requiredbooleanfalseIf true, the label is displayed as required.
readOnlybooleanIf true, Inputstepper will be readonly
onBlurevent => void \| PromiseFunction for handling onBlur event.
onChangenumber => void \| PromiseFunction for handling onClick event.
onFocusevent => void \| PromiseFunction for handling onFocus event.
reffuncProp for forwarded ref of the InputStepper. See Functional specs
sizeenum"normal"The size of the InputStepper.
spaceAfterenumAdditional margin-bottom after component. See this docs
stepnumber1Specifies the value of step to increment and decrement.
tabIndexstring \| numberSpecifies the tab order of an element
titleDecrementstring \| (any => string)Decrement valueSpecifies title property on decrement Button.
titleIncrementstring \| (any => string)Increment valueSpecifies title property on increment Button.
size
"small"
"normal"
  • The error prop overwrites the help prop, due to higher priority.

  • The color of the label will turn into cloud shade when the InputStepper has some filled value.

  • The prop defaultValue sets up the default value when component mounts. If you need to get the current and validated value of InputStepper, use arrow function for it, e.g.:

<InputStepper onChange={value => doSomething(value)} />
  • ref can be used for example auto-focus the elements immediately after render.
class Component extends React.PureComponent<Props> {
componentDidMount() {
this.ref.current && this.ref.current.focus();
}
ref: { current: React.ElementRef<*> | null } = React.createRef();
render() {
return <InputStepper ref={this.ref} />;
}
}

InputStepper offers a stateless version for your custom solutions. To use InputStepperStateless you’ll need to add the import

import InputStepperStateless from "@kiwicom/orbit-components/lib/InputStepper/InputStepperStateless";

Table below contains all types of the props available in InputStepperStateless component.

NameTypeDefaultDescription
disabledbooleanfalseIf true, the InputStepperStateless will be disabled.
disabledIncrementbooleanIf true, the increment Button will be disabled.
disabledDecrementbooleanIf true, the decrement Button will be disabled.
errorReact.NodeThe error to display beneath the InputStepperStateless. See Functional specs
helpReact.NodeThe help to display beneath the InputStepperStateless.
labelTranslationThe label for the InputStepperStateless. See Functional specs
maxValuenumberSpecifies the maximum value for the InputStepperStateless.
minValuenumber-∞Specifies the minimum value for the InputStepperStateless.
namestringThe name for the InputStepperStateless.
onBlurevent => void \| PromiseFunction for handling onBlur event.
onChangenumber => void \| PromiseFunction for handling onClick event.
onDecrementevent => void \| PromiseFunction for handling decrement event.
onFocusevent => void \| PromiseFunction for handling onFocus event.
onIncrementevent => void \| PromiseFunction for handling increment event.
onKeyDownevent => void \| PromiseFunction for handling onKeyDown event present on input.
reffuncProp for forwarded ref of the InputStepperStateless. See Functional specs
requiredbooleanfalseIf true, the label is displayed as required.
sizeenum"normal"The size of the InputStepperStateless.
spaceAfterenumAdditional margin-bottom after component. See this docs
stepnumber1Specifies the value of step to increment and decrement.
tabIndex`stringnumber`Specifies the tab order of an element
titleDecrement`string(any => string)`Specifies title property on decrement Button.
titleIncrement`string(any => string)`Specifies title property on increment Button.
value`numberstring`Specifies the value of the InputStepperStateless.
<InputStepperStateless value={"2 adults"} />

We provide you with helpers function for validation they can be imported like this:

import validateIncrement from "@kiwicom/orbit-components/lib/utils/validateIncrement";
import validateDecrement from "@kiwicom/orbit-components/lib/utils/validateDecrement";
NameTypeDefaultDescription
valuenumberSpecifies the the current value.
maxValuenumberSpecifies the maximum value for the InputStepperStateless.
stepnumber1Specifies the value of step to increment and decrement.
validateIncrement({ value, maxValue, step });

Helper function for validating decrement. Can be used with Stateless InputStepper to make custom validation easier.

NameTypeDefaultDescription
valuenumberSpecifies the the current value.
minValuenumber-∞Specifies the minimum value for the InputStepperStateless.
stepnumber1Specifies the value of step to increment and decrement.
validateDecrement({ value, minValue, step });