Skip to main content

Currency Input

The Currency Input component allows users to enter currency-formatted values. It’s especially useful for forms and financial applications where numerical values need to be formatted with currency symbols, decimal places, and thousand separators.

This component ensures consistent formatting of monetary values, prevents invalid input, and supports a range of customization options, such as currency type and precision.

Properties

Property
Description
Expected Value
LabelText to display as the label for the field.String (e.g. Reimbursement Amount).
PlaceholderA hint displayed to guide the user on what to enter.String (e.g. Enter the amount in USD).
Default valueThe default value that the component will hold when the app is loaded.Number (e.g. 83.67).
Decimal placesNumber of decimal places to show after the decimal point.Integer (e.g. 2).
Default CurrencySets the currency format to use by default.Select the default currency from the dropdown or update it dynamically using fx.
Enable currency changeAllows the user to select a different currency from a dropdown. If disabled, the user can enter only the default currency.Enable or disable it using the toggle button or use fx to update it dynamically.

Events

EventDescription
On changeTriggers when the user types in the input field.
On enter pressedTriggers whenever the user presses the enter key on the keyboard.
On focusTriggers whenever the user clicks inside the input field.
On blurTriggers whenever the user clicks outside the input field.
info

Check Action Reference docs to get detailed information about all the Actions.

Component Specific Actions (CSA)

The following actions of the component can be controlled using the component-specific actions (CSA), you can trigger it using an event or use a RunJS query.

Action
Description
RunJS Query
setValue( )Sets the value of the Currency Input field.components.currencyinput1.setValue(value)
setText( )Sets the value of the Currency Input field.components.currencyinput1.setText(value)
clear( )Clears the input field.components.currencyinput1.clear()
setFocus( )Sets the focus of the cursor on the input field.components.currencyinput1.setFocus()
setBlur( )Removes focus from the input field. .components.currencyinput1.setBlur()
setVisibility( )Sets the visibility of the component.components.currencyinput1.setVisibility(false)
setLoading( )Sets the loading state of the component.components.currencyinput1.setLoading(true)
setDisable( )Disables the component.components.currencyinput1.setDisable(true)
setCountryCode ( )Programmatically sets the country code.{{components.currencyinput1.setCountryCode("US")}}

Exposed Variables

Variable
Description
How To Access
valueHolds the value of the component.{{components.currencyinput1.value}}
labelHolds the value of the component's label.{{components.currencyinput1.label}}
isValidIndicates if the input meets validation criteria.{{components.currencyinput1.isValid}}
isMandatoryIndicates if the field is required.{{components.currencyinput1.isMandatory}}
isLoadingIndicates if the component is loading.{{components.currencyinput1.isLoading}}
isVisibleIndicates if the component is visible.{{components.currencyinput1.isVisible}}
isDisabledIndicates if the component is disabled.{{components.currencyinput1.isDisabled}}
countryHolds the selected country in the currency input component.{{components.currencyinput1.country}}
formattedValueHolds the currency-formatted value based on the input and selected country.{{components.currencyinput1.formattedValue}}

Validation

Validation Option
Description
Expected Value
Make this field mandatoryDisplays a 'Field cannot be empty' message if no value is entered.Enable/disable the toggle button or dynamically configure using fx.
RegexRegular Expression to validate the input.Regular Expression Pattern (e.g., ^\d+(\.\d{1,2})?$).
Min valueSets the minimum value allowed.Integer (e.g., 99).
Max valueSets the maximum value allowed.Integer (e.g., 1000).
Custom validationSpecifies a validation error message for specific conditions.Logical Expression (e.g., {{components.currencyinput1.value<99&&"Value needs to be more than $99"}}).

To add regex inside Custom Validation, you can use the below format:

Format: {{(<regexPattern>.test(<value>)) ? '' : 'Error message';}}

Example: {{(/^\d+(\.\d{1,2})?$/.test(components.currencyinput1.value)) ? '' : 'Invalid Input';}}

Additional Actions

Action
Description
Configuration Options
Loading stateEnables a loading spinner, often used with isLoading to indicate progress.Enable/disable the toggle button or dynamically configure the value by clicking fx and entering a logical expression.
VisibilityControls component visibility.Enable/disable the toggle button or dynamically configure the value by clicking fx and entering a logical expression.
DisableEnables or disables the component.Enable/disable the toggle button or dynamically configure the value by clicking fx and entering a logical expression.
TooltipProvides additional information on hover. Set a display string.String (e.g., Enter the amount in USD ).

Devices

Property
Description
Expected Value
Show on desktopMakes the component visible in desktop view.You can set it with the toggle button or dynamically configure the value by clicking fx and entering a logical expression.
Show on mobileMakes the component visible in mobile view.You can set it with the toggle button or dynamically configure the value by clicking fx and entering a logical expression.

Styles

Label

Label Property
Description
Configuration Options
TextSets the color of the component's label.Select the color or click on fx and input code that programmatically returns a Hex color code.
AlignmentSets the position of the label and input field.Select either side or top or click on fx to input code that programmatically returns an alignment value - side or top.
WidthSets the width of the input field.Keep the Auto width option for standard width or deselect it to modify the width using the slider or through code entry in fx that returns a numeric value.

Field

Field Property
Description
Configuration Options
BackgroundSets the background color of the component.Select the color or click on fx and input code that programmatically returns a Hex color code.
BorderSets the border color of the component.Select the color or click on fx and input code that programmatically returns a Hex color code.
TextSets the text color of the text entered in the component.Select the color or click on fx and input code that programmatically returns a hex color code.
Error textSets the text color of the validation message that is displayed.Select the color or click on fx and input code that programmatically returns a Hex color code.
IconAllows you to select an icon for the component.Enable the icon visibility, and select the icon and icon color. Alternatively, set it programmatically using fx.
Border radiusModifies the border radius of the component.Enter a number or click on fx and enter a code that programmatically returns a numeric value.
Box shadowSets the box shadow properties of the component.Select the box shadow color and adjust the related properties or set it programmatically using fx.

Container

Padding
Allows you to maintain a standard padding by enabling the Default option.