NumberField
With step, min/max values, and roundToStep
By default the step
prop will round to the nearest multiple of the step on blur and with the use of the spin buttons. If you want to allow any value, set roundToStep
to false
.
Currency
The formatOptions prop allows you to pass in any of the Intl.NumberFormat options. The displayed value will be formatted when the field is blurred.
Percent
PlusMinus
The NumberField component supports a plus/minus stepper. The showButtons prop will display the stepper buttons.
Within a Form
The NumberField component has unique change behavior compared to other form components. The onChange callback will only be fired when the field is blurred. It can create unpredictable behavior when used in a Form or a Formik context. To validate immediately onChange we recommend using an async onChange callback to set the field value and then validate the form or the field separately.
Analytics
The NumberField component is trackable through Kyber Analytics. This is the default analytics config.
export default {
value: 'NumberField',
actions: {
onChange: { type: 'NUMBERFIELD_CHANGE', payload: 'Change' },
},
};