Expand commentComment on line R9Resolved

Amount input

Amount inputs are fields specifically designed to capture and display monetary or amount-based numeric values in a structured, readable, and accessible format.

Introduction

Distinct from the standard number input, the amount input is optimized for values where numeric formatting is required (ex. currency, financial values, percentages, and measurements). It can present values using grouping, decimal separators, and symbols to provide contextual information to users.

This makes the component particularly useful for financial forms, payments, budgets, transactions, quotations, and other experiences where users enter financial or values requiring specific units and formatting.

Anatomy

Amount input anatomy
  1. 1.
    Label (Optional): a descriptive text that identifies the amount users are expected to enter. Labels should be concise and should communicate the purpose of the value rather than its formatting.
  2. 2.
    Optional indicator (Optional): indicates that providing an amount is not required.
  3. 3.
    Helper text (Optional): provides additional information about the expected amount, currency, restrictions, or other requirements.
  4. 4.
    Container: the visual wrapper for the input. It establishes the interactive area and communicates states such as hover, focus, error, disabled, and read-only.
  5. 5.
    Placeholder/Value: provides an example or hint before a value is entered. The value represents the number provided by the user and can be automatically formatted based on currency, percentage, or unit settings.

Form inputs

Form inputs allow users to enter or select data. Choosing an input that matches the type of information being collected helps improve task completion and data accuracy.

Amount input should be used when the numeric information being collected has value and formatting-specific presentation requirements. For numeric data where rigid formatting is unnecessary, use the more general number input instead.

Shared input characteristics

Amount input shares the common characteristics of other Halstack form inputs:

  • Placeholder: provides a hint or example of the expected value.
  • Helper text: provides instructions or additional information about the expected amount.
  • Optional label: communicates that entering a value is not mandatory.

Common input states

Most inputs can also present standard interactive or informative states:

  • Disabled: this state prevents users from interacting with the field. It's typically used when a value is not applicable or editable under certain conditions or roles.
  • Error: when a user enters invalid or incomplete data, the input shows an error state, often accompanied by a helpful message to guide corrections.
  • Read-only: the input is visible, focusable, and hoverable, but not editable. This is ideal for fields with auto-calculated values. Unlike disabled fields, read-only inputs can still be submitted with the form and are part of the form data.

Using amount inputs

Amount inputs should be used whenever users need to enter monetary values or other numeric values where amount formatting and readability are important.

Amount Input vs Number Input vs Text Input

  • Use amount input when the value represents an amount and requires currency-specific, percentage, or measurement unit formatting.
  • Use number input for discrete, countable quantities like Item counts, guests, age, or ratings where the numeric value itself is calculated or compared.
  • Use text input for general numeric values that need more flexibility or a combination of numbers and letters. These can include location information like address, contact number, and zip code.
NeedComponent
Address, phone number, zip codeText Input
Quantities that Increment/decrement with a defined step (ex. age, object count, ratings)Number Input
Currency or locale-formatted valuesAmount Input
Price, cost, payment or financial amounts that require specific digits, separators, decimals, or formattingAmount Input
Quantities with units (percent, weight, distance, volume)Amount Input

Formatting

Users should be able to type an amount directly into the field using familiar numeric input conventions.

The component should distinguish between a user's editing state and the formatted representation of the final value. This prevents formatting from interfering unnecessarily while users are entering or correcting an amount.

For example, a user typing:

1234567.89

may ultimately see:

1,234,567.89

after the value has been accepted and formatted.

Common use cases and corresponding amount input formatting examples:

Use caseExample
Currency$ 2,532.50
123.456,79 €
-3,500.00 US dollars
Units1,000 km
58.2 litres
Percentage97.999 %
2.5%
Digit grouping and separatorsR$ 1.250.500,75
1 250 500,75 €
₹12,50,500.75
Decimal values0.00075
9.81

Best practices

General

  • Always use clear labels: describe what the amount represents rather than relying on its formatting or currency symbol alone.
  • Make currency clear: when the value represents money, users should be able to determine which currency applies without relying on context elsewhere on the page.
  • Use helper text when necessary: explain constraints, expected values, or other requirements that cannot be inferred from the label.
  • Indicate optional fields: use the standard Halstack optional indicator when entering an amount is not mandatory.

Formatting

  • Format for readability, not decoration: thousand/grouping separators are especially useful for large values making them easier to read. Alignment also plays a significant role in improving the readability of multiple values, particularly those with fixed decimal digits.
  • Consider locale carefully and communicate it clearly with users: Decimal and grouping separators differ between locales. For example, 1,234.56 and 1.234,56 can represent the same amount under different conventions.

Validation

  • Provide useful validation messages: explain why an amount is invalid and, where possible, what users need to do to correct it.
  • Explain constraints in human-readable terms: for example, prefer “Enter an amount between $100 and $1,000” over a generic “Invalid value.”
  • Preserve user input when displaying an error: so users can correct the value rather than entering it again.