CurrencyInput

core package3.2.2

Note: All components shown on this site are supported by the Constellation design system. To learn how to configure Theme Cosmos, visit Pega Community.

The CurrencyInput component allows a user to enter a monetary value that will be auto-formatted to match a particular currency, such as pounds sterling, euros, dollars, etc.

To learn more about configuration, visit Pega Community.

Usage

The formatting for the value entered within the CurrencyInput (e.g., separators, decimals), as well as any numerical formatting necessary for a particular locale, will be applied as a user types. You can configure the locale of your application via the Configuration component.

The CurrencyInput component is built on top of the NumberInput and thus shares certain props such as unit, step, min and max. The component will only allow a user to enter numerical data and any other characters will be ignored. The unit placement (either at the start or end of the input) is determined based on the runtime environment's locale.

There are a variety of formatting options for the CurrencyInput component that enable you to show decimals, show group separators, and show the currency symbol. The component also allows for standard Form Field structures such as being set required, disabled, or readOnly, as well as including a label, status, or info. If an onResolveSuggestion callback function is provided, and the status is set to pending, the user will be prompted to accept or deny whatever suggested value populates the CurrencyInput.

If there is a label and the Field is not disabled, passing an object to the additionalInfo prop that includes a heading and content will provide the user with more useful information on the Field when they click on the associated information Icon.

Example

Enter a numerical value

Related components

Properties

NameDescriptionDefaultType
onChange*(value: string) => void
additionalInfoButton when clicked will show additional information
{
  content: string | Element;
  heading: string;
}
alwaysShowISOCodeAlways show ISO codefalseboolean
aria-labelOptional manual override for generated aria labelstring
autoFocusAutomatically focuses the input on render.boolean
classNameAdditional CSS classes.string
currencyISOCodeThree letter currency shorthand ISO code. If not provided or invalid, component renders as NumberInputstring
disabledDisable the control. The browser defaults to false.boolean
idSets DOM id for the control and associates label element via 'for' attribute. If an id is not pass, a random id will be generated for any render.string
infoIt is recommended to pass a simple string to offer guidance. Text will be styled based on status prop.ReactNode
labelPass a string or a fragment with an Icon and string.ReactNode
labelHiddenVisually hides the label region.falseboolean
maxThe maximum value to accept for this input. This value must be greater than or equal to the value of the min attribute.Number.MAX_SAFE_INTEGERnumber
maximumFractionDigitsFixed number of maximum fraction digits.number
minThe minimum value to accept for this input. This value must be less than or equal to the value of the max attribute.Number.MIN_SAFE_INTEGERnumber
minimumFractionDigitsFraction digits consistent with ISOnumber
nameSets html name attribute for the underlying control. Useful for mapping to a data field.string
onBlur(value: string) => void
onFocus(value: string) => void
onResolveSuggestion(accepted: boolean) => void
placeholderPlaceholder text. The browser defaults to an empty string.string
readOnlyMakes the component non editable and non clickable. The browser defaults to false.boolean
refRef for the wrapping element.Ref<HTMLInputElement>
requiredIndicate if the field is required. The browser defaults to false.boolean
showDecimal/** Determines whether decimal places should be shown. The value is rounded if true.trueboolean
showGroupSeparatorsDetermines whether group separators should be shown.trueboolean
statusSet visual state based on a validation state.
'error' |'pending' |'success' |'warning' 
stepA stepping interval to use when using up and down arrows to adjust the value.1number
unitDefines unit of the number, like 'kg', 'miles' or '%'.string
valueCurrencyInput input value. Requires an onChange handler to update value.string
variantComponent variation. Might be rendered as regular input or stepper.'default'
'default' |'stepper'