How to use currency format to fill decimal/cents first?
See original GitHub issueConsider the following input value:
12345
The output would be:
$ 123.45
instead of $ 1,2345.00
.
How to achieve the first output using this library?
This is how I am using right now, unfortunately I couldn’t make it work as desired:
<NumberFormat
customInput={Input}
decimalScale={2}
decimalSeparator=","
fixedDecimalScale
onKeyDown={onEnter(handleEnter)}
onValueChange={handleValueChange}
placeholder="$ 0,00"
prefix="$ "
thousandSeparator="."
value={value}
/>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:16 (1 by maintainers)
Top Results From Across the Web
How do you format a number to currency when using React ...
You can use toFixed method for showing 2 decimal point. let num = 1000; console.log(num.toFixed(2)); // 1000.00. And you can use Regex like ......
Read more >Format numbers as currency - Microsoft Support
In the Decimal places box, enter the number of decimal places that you want for the number. For example, to display $138,691 instead...
Read more >React js Number Format and styling | by Nidhin kumar
style — The formatting style to use. Possible values are "decimal" for plain number formatting, "currency" for currency formatting, ...
Read more >Custom Excel number format - Ablebits
If a custom number format includes 2 sections, the first section is used ... after a number to fill the cell, use this...
Read more >International Currency Conversion - DFA Cornell
United States (U.S.) currency is formatted with a decimal point (.) as a separator between the dollars and cents. Some countries use a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@felri I’ve found out how to format the number properly - using a formatter. The trick is to divide value by 100.
Then you must use this format into your component:
Yeah. This is expected because the approach is based on a formatter only. So it will only change how the number is displayed. You must handle the float number and divide it by 100 before persisting it or whatever you do with this number.
An alternative could be if a implementation is made to make this feature native, then we could expect float number also be divide by 100 automatically.
You could also implement your own wrapper to this component and expose a float number already divided by 100.