Money field
The money field component collects monetary values from users with built-in currency formatting and validation. Use money field for prices, costs, or financial amounts to provide proper currency symbols, decimal handling, and numeric validation.
Money fields support currency codes, automatic formatting, and min/max constraints to ensure users enter valid monetary values. For non-currency numeric input, use number field.
Anchor to PropertiesProperties
Configure the following properties on the money field component.
- Anchor to maxmaxmaxnumbernumberDefault: InfinityDefault: Infinityrequiredrequired
The highest decimal or integer value accepted for the field. When used with
step, the value rounds down to the maximum number.Users can still type values higher than the maximum using the keyboard. Implement validation to enforce this constraint.
- Anchor to minminminnumbernumberDefault: -InfinityDefault: -Infinityrequiredrequired
The lowest decimal or integer value accepted for the field. When used with
step, the value rounds up to the minimum number.Users can still type values lower than the minimum using the keyboard. Implement validation to enforce this constraint.
- Anchor to valuevaluevaluestringstringrequiredrequired
The current monetary value in the field as a string. When setting this property programmatically, it updates the field's display value. When reading it, you get the user's current input. The value should be a numeric string representing the amount in the store's currency.
- Anchor to autocompleteautocompleteautocompletestringstringDefault: 'on' for everything elseDefault: 'on' for everything elserequiredrequired
Controls browser autofill behavior for the field.
Basic values:
on- Enables autofill without specifying content type (default)off- Disables autofill for sensitive data or one-time codes
Specific field values describe the expected data type. You can optionally prefix these with:
section-${string}- Scopes autofill to a specific form section (when multiple forms exist on the same page)shippingorbilling- Indicates whether the data is for shipping or billing purposes- Both section and group (for example,
section-primary shipping email)
Providing a specific autofill token helps browsers suggest more relevant saved data.
Learn more about the set of autocomplete values supported in browsers.
- Anchor to defaultValuedefaultValuedefaultValuestringstringrequiredrequired
The initial value of the field when it first loads. Unlike
placeholder, this is a real value that the user can edit and that gets submitted with the form. Once the user starts typing, their input replaces it. Changing this property after the field has loaded has no effect. To update the field value at any time, usevalueinstead.- Anchor to detailsdetailsdetailsstringstringrequiredrequired
Supplementary text displayed below the checkbox to provide additional context, instructions, or help. Use this to explain what checking the box means or provide guidance to users. This text is announced to screen readers.
- Anchor to errorerrorerrorstringstringrequiredrequired
An error message displayed below the checkbox to indicate validation problems. When set, the checkbox is styled with error indicators and the message is announced to screen readers.
- Anchor to labellabellabelstringstringrequiredrequired
The text displayed as the field label, which identifies the purpose of the field to users. This label is associated with the field for accessibility and helps users understand what information to provide.
- Anchor to labelAccessibilityVisibilitylabelAccessibilityVisibilitylabelAccessibilityVisibility"visible" | "exclusive""visible" | "exclusive"Default: 'visible'Default: 'visible'requiredrequired
Controls whether the label is visible to all users or only to screen readers.
visible: The label is shown to everyone (default).exclusive: The label is visually hidden but still announced by screen readers.
Use
exclusivewhen the surrounding context makes the label redundant visually, but screen reader users still need it for clarity.- Anchor to placeholderplaceholderplaceholderstringstringrequiredrequired
The placeholder text displayed in the field when it's empty, providing a hint about the expected input format or value.
- Anchor to readOnlyreadOnlyreadOnlybooleanbooleanDefault: falseDefault: falserequiredrequired
Whether the field is read-only and can't be edited. Read-only fields remain focusable and their content is announced by screen readers.
- Anchor to requiredrequiredrequiredbooleanbooleanDefault: falseDefault: falserequiredrequired
Whether the field requires a value before form submission. Displays a visual indicator and adds semantic meaning, but doesn't automatically validate or show errors. Use the
errorproperty to display validation messages.- Anchor to disableddisableddisabledbooleanbooleanDefault: falseDefault: falserequiredrequired
Whether the field is disabled, preventing any user interaction.
- Anchor to idididstringstringrequiredrequired
A unique identifier for the element. Use this to reference the element in JavaScript, link labels to form controls, or target specific elements for styling or scripting.
- Anchor to namenamenamestringstringrequiredrequired
The name attribute for the field, used to identify the field's value when the form is submitted. Must be unique within the nearest containing form.
Anchor to EventsEvents
The money field component provides event callbacks for handling user interactions. Learn more about handling events.
- Anchor to blurblurblurCallbackEventListener<'input'>CallbackEventListener<'input'>requiredrequired
A callback fired when the money field loses focus.
Learn more about the blur event.
- Anchor to changechangechangeCallbackEventListener<'input'>CallbackEventListener<'input'>requiredrequired
A callback fired when the money field value changes.
Learn more about the change event.
- Anchor to focusfocusfocusCallbackEventListener<'input'>CallbackEventListener<'input'>requiredrequired
A callback fired when the money field receives focus.
Learn more about the focus event.
- Anchor to inputinputinputCallbackEventListener<'input'>CallbackEventListener<'input'>requiredrequired
A callback fired when the user inputs data into the money field.
Learn more about the input event.
CallbackEventListener
A function that handles events from UI components. This type represents an event listener callback that receives a `CallbackEvent` with a strongly-typed `currentTarget`. Use this for component event handlers like `click`, `focus`, `blur`, and other DOM events.
(EventListener & {
(event: CallbackEvent<T>): void;
}) | nullCallbackEvent
An event object with a strongly-typed `currentTarget` property that references the specific HTML element that triggered the event. This type extends the standard DOM `Event` interface and ensures type safety when accessing the element that fired the event.
Event & {
currentTarget: HTMLElementTagNameMap[T];
}Anchor to ExamplesExamples
Anchor to Collect a currency valueCollect a currency value
Capture monetary values with automatic currency formatting. This example pairs a label with placeholder text and helper details.
Preview
html
Anchor to Add a label and constraintsAdd a label and constraints
Set input boundaries for valid amounts. This example configures min/max limits to constrain the accepted value range.
Preview
html
Anchor to Handle validation errorsHandle validation errors
Communicate input problems clearly to users. This example displays an error message when the entered value is invalid.
Preview
html
Anchor to Combine multiple fields in a formCombine multiple fields in a form
Collect multiple monetary values in a single form. This example groups money fields for price, compare-at price, and cost with individual constraints.
Preview
html
Anchor to Best practicesBest practices
- Set realistic min/max constraints: For product prices, use
min={0.01}to prevent zero prices. For discounts, usemin={0}andmax={orderTotal}. For refunds, usemax={amountPaid}. Always validate against business logic limits. - Provide specific validation feedback: Instead of Invalid amount, show Price must be at least $0.01 or Discount can't exceed $50.00 order total. Explain the exact constraint violated.
- Never add currency symbols to labels: Don't add $ or other currency symbols to the label or placeholder, as this can create confusion with any currency formatting the component provides.
- Label by specific monetary purpose: Use labels like Product base price, Discount amount, Shipping rate per kg, or Subscription renewal fee instead of vague Amount or Price.
- Pre-fill when editing existing values: Always populate the field with the current value when editing. For new entries, consider smart defaults like 0.00 or typical price points for your product category.
Anchor to LimitationsLimitations
- The component outputs values as strings, but converting to JavaScript numbers for arithmetic can cause floating-point precision errors. Always perform critical financial calculations on the server using decimal-precise arithmetic or integer cents (multiply by 100).
- The component formats currency based on the merchant's store currency and locale. The same numeric value might display as $1,234.56 (en-US) vs 1 234,56 $ (fr-FR). Test your UI with various currency/locale combinations if you operate internationally.
- Currencies like JPY (Â¥), KRW (â‚©), and VND (â‚«) don't use decimal places. The component might still allow decimal input but this will be invalid for these currencies. Validate the currency's decimal places on the backend.
- The component doesn't perform currency conversion. If you need to display amounts in multiple currencies, you must handle conversion rates and calculations separately.