Skip to main content

Number Input

Accepts numerical input either by typing or pressing the + or - buttons.

Examples

Basic Number Input

When the disabled prop is passed, the input will be inactive.

import { NumberInput } from '@curology/ui-components-web/react/NumberInput';

<NumberInput />

With Constraints and Step

With a min, max, or step provided, the Number input will prevent the user from going below min or above max. Using the + or - buttons will increment or decrement based on the size of the step.

import { NumberInput } from '@curology/ui-components-web/react/NumberInput';

<NumberInput
min="5"
max="100"
step="5"
/>

Controlled Number Input

Like all form inputs, a NumberdInput can either be uncontrolled, or controlled (by providing a value and onChange listener).

Current value: 10
import { NumberInput } from '@curology/ui-components-web/react/NumberInput';

<NumberInput
...
value={someValue}
onChange={handleChange}
/>

Props

NumberInputProps

NameTypeDefault ValueRequiredDescription
All attributes of a <input />
defaultValuestring | numberNoA starting value for an uncontrolled component.
onChangeFormControlChangeEventHandler<HTMLInputElement, number>NoEmit a new value when the input's value changes.
valuestring | numberNoA current value for a controlled component.