Currency Input
Overview
Use the currency input component to prompt the user to enter a currency value.
![Currency input](./CurrencyInput.png?v=2)
Development
Web component development
Component reference
p-inputNumber
Allows user to edit values that have a currency format
View the p-inputNumber reference doc
If you're adding PrimeNG to your solution for the first time, reference their setup documentation. It's important to note that the inclusion of the nova-light theme css is not necessary to work with Responsive UI. Styling for the PrimeNG components is provided by Responsive UI's theming.
Implementation
Begin by importing the InputNumberModule
module into your application.
import { InputNumberModule } from 'primeng/inputnumber';
Add a PrimeNG p-inputNumber
component with mode="decimal" locale="en-US"
to specify a currency input. Also bind minFractionDigits
and maxFractionDigits
to 2 and step
to 0.01. Add rui-form-control
as the inputStyleClass
to inherit the correct styling.
Add <span class="input-group-addon">$</span>
before the p-inputNumber
element to display a dollar sign before the input. Nest both this span
and the p-inputNumber
within a div
that has the input-group
CSS class.
<div class="input-group">
<span class="input-group-addon">$</span>
<p-inputNumber formControlName="grossIncome" inputId="GrossIncome" inputStyleClass="rui-form-control"
mode="decimal" locale="en-US" [minFractionDigits]="2" [maxFractionDigits]="2" [step]="0.01"></p-inputNumber>
</div>
Angular component development
Component reference
p-inputNumber
Allows user to edit values that have a currency format
View the p-inputNumber reference doc
If you're adding PrimeNG to your solution for the first time, reference their setup documentation. It's important to note that the inclusion of the nova-light theme css is not necessary to work with Responsive UI. Styling for the PrimeNG components is provided by Responsive UI's theming.
Implementation
Begin by importing the InputNumberModule
module into your application.
import { InputNumberModule } from 'primeng/inputnumber';
Add a PrimeNG p-inputNumber
component with mode="decimal" locale="en-US"
to specify a currency input. Also bind minFractionDigits
and maxFractionDigits
to 2 and step
to 0.01. Add rui-form-control
as the inputStyleClass
to inherit the correct styling.
Add <span class="input-group-addon">$</span>
before the p-inputNumber
element to display a dollar sign before the input. Nest both this span
and the p-inputNumber
within a div
that has the input-group
CSS class.
<div class="input-group">
<span class="input-group-addon">$</span>
<p-inputNumber formControlName="grossIncome" inputId="GrossIncome" inputStyleClass="rui-form-control"
mode="decimal" locale="en-US" [minFractionDigits]="2" [maxFractionDigits]="2" [step]="0.01"></p-inputNumber>
</div>
Design
Figma design
Dev Component | Design Component Name |
---|---|
Currency input | RUI / Forms / Currency Input |
Adobe XD design
- Sample App - Editing Form Data
Dev Component | Design Component Name |
---|---|
Currency input | JHA / Forms / Currency Input |