Number Field
Usage
Number Field is a numeric input control for values that should be numeric, such as quantities, counts, percentages, or other values that benefit from step-based input. Use it when min and max limits should guide valid input.
import { MtNumberField } from "@shopware-ag/meteor-component-library";
Examples
Disabled
Error
Hint
API reference
Props
| Prop | Type | Default |
|---|---|---|
copyableToggles the copy function of the text field. | boolean | false |
errorAn error in your business logic related to this field. | Record<string, any> | null |
labelA label for your text field. Usually used to guide the user what value this field controls. | string | null |
requiredDetermines if the field is required. | boolean | false |
is-inheritance-fieldDetermines if the field is inheritable. | boolean | false |
is-inheritedToggles the inheritance visualization. | boolean | false |
help-textA text that helps the user to understand what this field does. | string | null |
disabledDetermines if the field is disabled. | boolean | false |
placeholderA placeholder text being displayed if no value is set. | string | "" |
name | string | null |
sizeThe size of the text field. | string | "default" |
model-valueThe value of the text field.
The value of the number field. | number | null |
disable-inheritance-toggleDetermines the active state of the inheritance toggle. | boolean | false |
copyable-tooltipIf set to true the tooltip will change on successful copy. | boolean | false |
max-lengthIf set to a value a character counter will be displayed. | number | undefined |
id-suffix | string | "" |
number-typeDefines if the number should be a floating point number or integer. | "float" | "int" | "float" |
stepDefines the amount of which the number is increased or decreased per step. | number | null |
minDefines the minimum value of the number. | number | null |
maxDefines the maximum value of the number. | number | null |
digitsDefines how many digits should be displayed after the decimal point. | number | 2 |
fill-digitsDefines if digits should be filled with zeros if the value is smaller than the minimum value. | boolean | false |
allow-emptyDefines if the field can be empty. | boolean | undefined |
number-align-endDefines if the number should be aligned to the end of the input field. | boolean | false |
show-controlsDefines if the control arrows should be visible. | boolean | true |
on-update:model-value | ((...args: any[]) => any) | undefined | |
on-change | ((...args: any[]) => any) | undefined | |
on-inheritance-remove | ((...args: any[]) => any) | undefined | |
on-inheritance-restore | ((...args: any[]) => any) | undefined | |
on-blur | ((...args: any[]) => any) | undefined | |
on-focus | ((...args: any[]) => any) | undefined | |
on-input-change | ((...args: any[]) => any) | undefined |
Exposed
| Name | Type |
|---|---|
t | ComposerTranslation<{ en: { increaseButton: string; decreaseButton: string; }; de: { increaseButton: string; decreaseButton: string; }; }, "en" | "de", RemoveIndexSignature<{ [x: string]: LocaleMessageValue<VueMessageType>; }>, never, "increaseButton" | "decreaseButton", "increaseButton" | "decreaseButton"> |
currentValue | string | number |
hasFocus | boolean |
rawUserInput | string | null |
hasError | boolean |
hasDisabledInput | boolean |
realStep | number |
realMinimum | number | null |
realMaximum | number | null |
stringRepresentation | string |
controlClasses | { "mt-field__controls--disabled": boolean; "mt-field__controls--has-error": boolean; "mt-field__controls--small": boolean; } |
allowEmptyWithDefault | boolean |
onInput | ((event: Event) => void) & ((event: Event) => void) |
Best practices
Do
- Use a clear label that explains what the number represents.
- Configure
step,min, andmaxwhen the range is known. - Choose the right
numberTypefor integer or decimal input.
Don't
- Do not use Number Field for values that are identifiers but look numeric.
- Do not use it when users need to pick both a number and a unit together.
- Do not hide important limits from users if the field enforces them.
Behavior
- Number Field builds on the shared field base and adds numeric parsing, stepping, and optional arrow controls.
numberType,digits,fillDigits, andnumberAlignEndhelp tune how numeric values are entered and displayed.showControlscan show increase and decrease buttons for step-based adjustment.
Accessibility
- Always provide a visible label that explains the meaning of the number.
- Use help text when users need context about valid ranges, units, or rounding.
- Make sure any min, max, or step behavior matches the expectations shown in the UI.
Related components
- Text Field: when numeric-looking content should stay as plain text.