Input Currency (Deprecated)

ui:inputCurrency

Deprecated as of API version 47.0. We recommend migrating to Lightning Web Components and using the lightning-input component.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App

Deprecation Guidelines 

We recommend using Lightning Web Components whenever possible. When migrating to Lightning Web Components, use lightning-input with number type and currency formatter.

For more information, see Aura Components in the ui Namespace Are Deprecated.

Usage Overview (Deprecated) 

A ui:inputCurrency component represents an input field for a number as a currency, which is rendered as an HTML input element of type text. It uses JavaScript’s Number type MAX_SAFE_INTEGER and MIN_SAFE_INTEGER precision to determine the supported number of digits, which is about 16 digits. Numbers outside of the precision can get truncated or rounded.

To apply Lightning Design System styling, we recommend that you use lightning:input with type="number" and formatter="currency" instead of ui:inputCurrency. To render the output from a ui:inputCurrency component, use the ui:outputCurrency component.

This is a basic set up of a ui:inputCurrency component, which renders an input field with the value $50.00 when the browser’s currency locale is $.

1<ui:inputCurrency aura:id="amount" label="Amount" class="field" value="50" />

This example results in the following HTML.

1<div class="uiInput uiInput--default uiInput--input">
2  <label class="uiLabel-left form-element__label uiLabel">
3    <span>Amount</span>
4  </label>
5  <input class="field input" max="99999999999999" step="1" type="text" min="-99999999999999" />
6</div>

To override the browser’s locale, set the new format on the v.format attribute of the ui:inputCurrency component. This example renders an input field with the value £50.00.

1var curr = component.find("amount");
2curr.set("v.format", "£#,###.00");

To create forms for Salesforce objects without using Apex controllers, use lightning:inputField with lightning:recordEditForm, or use lightning:recordForm. To create an input field for different data types, use lightning:input.

Note

Attributes 

NameDescriptionTypeDefaultRequired
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]
classA CSS style to be attached to the component. This style is added in addition to base styles output by the component.String
disabledSpecifies whether the component should be displayed in a disabled state. Default value is "false".Booleanfalse
errorsThe list of errors to be displayed.Object[]
formatThe format of the number. For example, format=“.00” displays the number followed by two decimal places. If not specified, the Locale default format will be used.String
labelThe text of the label componentString
labelClassThe CSS class of the label componentString
maxlengthThe maximum number of characters that can be typed into the input field. Corresponds to the maxlength attribute of the rendered HTML input element.Integer
placeholderText that is displayed when the field is empty, to prompt the user for a valid entry.String
requiredSpecifies whether the input is required. Default value is "false".Booleanfalse
requiredIndicatorClassThe CSS class of the required indicator componentString
sizeThe width of the input field, in characters. Corresponds to the size attribute of the rendered HTML input element.Integer
updateOnUpdates the component's value binding if the updateOn attribute is set to the handled event. Default value is "change".Stringchange
valueThe input value of the number.Decimal
valueThe value currently in the input field.String