NumberField
The <NumberField>
component used for capturing numerical input from the user in a form or similar input context. This allows users to input numbers including integers, decimals, and as well as percentages.
The component also offers steppers which provides lower interaction costs.
Anatomy
It consists of a label, an input field and a help text. Optional you can also show a help text and stepper buttons for increasing/decreasing values.

Appearance
The appearance of a component can be customized using the variant
and size
props. These props adjust the visual style and dimensions of the component, available values are based on the active theme.
Property | Type | Description |
---|---|---|
variant | - | The available variants of this component. |
size | - | The available sizes of this component. |
Usage
<NumberField>
is an input field that accepts only numeric input.
Use Steppers
The stepper buttons make it easier and faster for people to make small numeric changes. It allows people to increase or decrease a number with a single button press, or by typing the number in the field.
If you don't want the step buttons to appear, you can easily remove these
with the hideStepper
property.
Also keep in mind using the width
property is essential to provide a good user experience. So each input field shouldn't be larger than the expected content. For example
when using stepper buttons it is better to have shorter fields, so that the user can easier reach these buttons (lower interaction costs).
Confirm Guests
Use steppers to make small numeric changes, else the interaction cost would be high.
Use Format Options
With <NumberField>
you can use Intl.NumberFormatOptions
which comes in handy to format the numbers in a certain format, e.g. percent
,unit
, decimal
and currency
.
For a full list of supported options, see corresponding MDN Docs. A full list of suported units can be seen here.
In addition, use units to support the label and make it clear what the user is entering in a particular number field.
Label
In general label should be short and precise about what is expected from the user. Avoid unnecessary instructional verbs (doing words) in your labels and hints because it’s already implied by the input field. Avoid placeholder text in most cases, as there’s no need for it (more about it in the next section).


Don’t use unnecessary instructional verbs.
Placeholder
Placeholder text is a short hint displayed inside an input field before a user enters a value. To save space, placeholder text is often used instead of a label, as shown in the first example. This is problematic for the following reasons:
- Placeholder text disappears once a person starts filling in an input field, causing some to forget what the field was for
- Some might miss or skip fields with placeholder text, as it can look like the field has already been pre-filled.
- Placeholder text colour contrast is almost always inaccessible, as it’s very light by design. This means many will struggle to read the label.


Don’t use placeholder text instead of a label.
Additional Description
Sometimes the label isn't enough for the user. In this case, to gather additional support for the user we can use the help text. With this we can add helpful hints for the user below the input field. Beside that the help text is placed in close proximity to the associated input field.

Use help text to show an example what's expected.

NumberField With An Error
Error messages should let people know that a problem occurred, why it happened, and provide a solution to fix it and move forward.

Never blame the user. Always be positive and helpful.

Be concise and avoid unnecessary words like “please”, “sorry” and “oops”

Use detailed messages instead of global messages.
The error
prop toggles the error state of a field. The errorMessage
prop can then be used to provide feedback to
the user about the error. The message disappears automatically when all requirements are met.
Press Enter
, after typing your text, to trigger the validation.
Props
aria-describedby?
string;
aria-details?
string;
aria-label?
string;
aria-labelledby?
string;
autoFocus?
boolean;
decrementAriaLabel?
string;
defaultValue?
number;
description?
ReactNode;
dir?
string;
disabled?
boolean;
true
, the input is disabled."false"
error?
boolean;
true
, the field is considered invalid and if set the errorMessage is shown instead of the description
."false"
errorMessage?
ReactNode | ((v: ValidationResult) => ReactNode);
form?
string;
<form>
element to associate the input with.
The value of this attribute must be the id of a <form>
in the same document.
See MDN.formatOptions?
NumberFormatOptions;
hidden?
boolean;
hideStepper?
boolean;
"false"
id?
string;
incrementAriaLabel?
string;
inert?
boolean;
isWheelDisabled?
boolean;
label?
ReactNode;
lang?
string;
maxValue?
number;
minValue?
number;
name?
string;
onAnimationEnd?
AnimationEventHandler<HTMLDivElement>;
onAnimationEndCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationIteration?
AnimationEventHandler<HTMLDivElement>;
onAnimationIterationCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationStart?
AnimationEventHandler<HTMLDivElement>;
onAnimationStartCapture?
AnimationEventHandler<HTMLDivElement>;
onAuxClick?
MouseEventHandler<HTMLDivElement>;
onAuxClickCapture?
MouseEventHandler<HTMLDivElement>;
onBeforeInput?
FormEventHandler<HTMLInputElement>;
onBlur?
(e: FocusEvent<Element, Element>) => void;
onChange?
(value: number) => void;
onClick?
MouseEventHandler<HTMLDivElement>;
onClickCapture?
MouseEventHandler<HTMLDivElement>;
onCompositionEnd?
CompositionEventHandler<HTMLInputElement>;
onCompositionStart?
CompositionEventHandler<HTMLInputElement>;
onCompositionUpdate?
CompositionEventHandler<HTMLInputElement>;
onContextMenu?
MouseEventHandler<HTMLDivElement>;
onContextMenuCapture?
MouseEventHandler<HTMLDivElement>;
onCopy?
ClipboardEventHandler<HTMLInputElement>;
onCut?
ClipboardEventHandler<HTMLInputElement>;
onDoubleClick?
MouseEventHandler<HTMLDivElement>;
onDoubleClickCapture?
MouseEventHandler<HTMLDivElement>;
onFocus?
(e: FocusEvent<Element, Element>) => void;
onFocusChange?
(isFocused: boolean) => void;
onGotPointerCapture?
PointerEventHandler<HTMLDivElement>;
onGotPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onInput?
FormEventHandler<HTMLInputElement>;
onKeyDown?
(e: KeyboardEvent) => void;
onKeyUp?
(e: KeyboardEvent) => void;
onLostPointerCapture?
PointerEventHandler<HTMLDivElement>;
onLostPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onMouseDown?
MouseEventHandler<HTMLDivElement>;
onMouseDownCapture?
MouseEventHandler<HTMLDivElement>;
onMouseEnter?
MouseEventHandler<HTMLDivElement>;
onMouseLeave?
MouseEventHandler<HTMLDivElement>;
onMouseMove?
MouseEventHandler<HTMLDivElement>;
onMouseMoveCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOut?
MouseEventHandler<HTMLDivElement>;
onMouseOutCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOver?
MouseEventHandler<HTMLDivElement>;
onMouseOverCapture?
MouseEventHandler<HTMLDivElement>;
onMouseUp?
MouseEventHandler<HTMLDivElement>;
onMouseUpCapture?
MouseEventHandler<HTMLDivElement>;
onPaste?
ClipboardEventHandler<HTMLInputElement>;
onPointerCancel?
PointerEventHandler<HTMLDivElement>;
onPointerCancelCapture?
PointerEventHandler<HTMLDivElement>;
onPointerDown?
PointerEventHandler<HTMLDivElement>;
onPointerDownCapture?
PointerEventHandler<HTMLDivElement>;
onPointerEnter?
PointerEventHandler<HTMLDivElement>;
onPointerLeave?
PointerEventHandler<HTMLDivElement>;
onPointerMove?
PointerEventHandler<HTMLDivElement>;
onPointerMoveCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOut?
PointerEventHandler<HTMLDivElement>;
onPointerOutCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOver?
PointerEventHandler<HTMLDivElement>;
onPointerOverCapture?
PointerEventHandler<HTMLDivElement>;
onPointerUp?
PointerEventHandler<HTMLDivElement>;
onPointerUpCapture?
PointerEventHandler<HTMLDivElement>;
onScroll?
UIEventHandler<HTMLDivElement>;
onScrollCapture?
UIEventHandler<HTMLDivElement>;
onSelect?
ReactEventHandler<HTMLInputElement>;
onTouchCancel?
TouchEventHandler<HTMLDivElement>;
onTouchCancelCapture?
TouchEventHandler<HTMLDivElement>;
onTouchEnd?
TouchEventHandler<HTMLDivElement>;
onTouchEndCapture?
TouchEventHandler<HTMLDivElement>;
onTouchMove?
TouchEventHandler<HTMLDivElement>;
onTouchMoveCapture?
TouchEventHandler<HTMLDivElement>;
onTouchStart?
TouchEventHandler<HTMLDivElement>;
onTouchStartCapture?
TouchEventHandler<HTMLDivElement>;
onTransitionCancel?
TransitionEventHandler<HTMLDivElement>;
onTransitionCancelCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionEnd?
TransitionEventHandler<HTMLDivElement>;
onTransitionEndCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionRun?
TransitionEventHandler<HTMLDivElement>;
onTransitionRunCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionStart?
TransitionEventHandler<HTMLDivElement>;
onTransitionStartCapture?
TransitionEventHandler<HTMLDivElement>;
onWheel?
WheelEventHandler<HTMLDivElement>;
onWheelCapture?
WheelEventHandler<HTMLDivElement>;
placeholder?
string;
"none"
readOnly?
boolean;
true
, the input is readOnly."false"
ref?
Ref<HTMLInputElement>;
ref.current
to null
(or call the ref with null
if you passed a callback ref).
@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}required?
boolean;
true
, the input is required."false"
slot?
string | null;
null
value indicates that the local props completely override all props received from a parent.step?
number;
translate?
"yes" | "no";
validate?
(value: number) => true | ValidationError | null;
validationBehavior="native"
. For realtime validation, use the isInvalid
prop instead.validationBehavior?
"native" | "aria";
'native'
value?
number;
width?
WidthProp;
"full"