Shopware Design

Unit Field

Source

Usage

Unit Field is a numeric input combined with a unit selector for measurements such as lengths, weights, or other values that may switch between compatible units. Use it when users should enter a value together with a measurement unit, and when unit conversion should happen as part of the input flow.

import { MtUnitField } from "@shopware-ag/meteor-component-library";

Examples

Disabled

Error

API reference

Props

PropTypeDefault
default-unit *convert.Unit"mm"
measurement-type"length" | "mass""length"
model-valuenumberundefined
placeholderstring
number-type"float" | "int"
stepnumber1
minnumber
maxnumber
digitsnumber
fill-digitsboolean
allow-emptyboolean
number-align-endboolean
labelstring
errorobject
disabledboolean
requiredboolean
namestring
sizestring
help-textstring
is-inheritedboolean
is-inheritance-fieldboolean
disable-inheritance-toggleboolean
copyableboolean
copyable-tooltipboolean
z-indexnumber | nullnull

Events

EventPayload
update:modelValue[value: number | undefined]
inheritance-remove[]
inheritance-restore[]
update:defaultUnit[value: convert.Unit]
update:measurementType[value: "length" | "mass"]

Best practices

Do
  • Use a clear label that explains what is being measured.
  • Set a sensible defaultUnit for the most common case.
  • Choose the right measurementType so the available units match the use case.
Don't
  • Do not use Unit Field when the unit is fixed and never changes.
  • Do not use it for non-measurement values such as counts or identifiers.
  • Do not hide the meaning of the measurement behind a vague label.

Behavior

  • Unit Field combines Number Field behavior with a unit selector.
  • Changing the selected unit can convert the current value to keep the measurement consistent.
  • measurementType controls which units are available, and defaultUnit controls the current selection.

Accessibility

  • Always provide a visible label so users understand what the measurement refers to.
  • Make sure unit changes remain understandable, especially when the displayed numeric value updates after conversion.
  • Use help text when users need guidance about accepted ranges or preferred units.
  • Number Field: when the value is numeric and the unit is fixed or communicated elsewhere.