Gathering detailed insights and metrics for react-native-currency-input
Gathering detailed insights and metrics for react-native-currency-input
Gathering detailed insights and metrics for react-native-currency-input
Gathering detailed insights and metrics for react-native-currency-input
A simple currency input component for both iOS and Android
npm install react-native-currency-input
Typescript
Module System
Node Version
NPM Version
TypeScript (37.68%)
Java (31.27%)
C++ (14.28%)
Objective-C++ (8.76%)
Ruby (3.21%)
JavaScript (2.78%)
Objective-C (1.15%)
CMake (0.53%)
C (0.2%)
Swift (0.13%)
Total Downloads
2,254,729
Last Day
430
Last Week
16,999
Last Month
72,863
Last Year
898,832
MIT License
165 Stars
27 Commits
25 Forks
3 Watchers
1 Branches
1 Contributors
Updated on Jun 13, 2025
Latest Version
1.1.1
Package Id
react-native-currency-input@1.1.1
Unpacked Size
112.97 kB
Size
22.21 kB
File Count
51
NPM Version
9.5.1
Node Version
18.16.0
Published on
Sep 19, 2023
Cumulative downloads
Total Downloads
Last Day
0.9%
430
Compared to previous day
Last Week
-2.7%
16,999
Compared to previous week
Last Month
-14.5%
72,863
Compared to previous month
Last Year
44.5%
898,832
Compared to previous year
2
19
A simple currency input component for both iOS and Android.
The goal of react-native-currency-input
is to offer a simple and effective way to handle number inputs with custom format, usually a currency input, but it can be used for any number input case.
formatNumber
<TextInput/>
component, so you can use its props and it's easy to customizeprecision
, delimiter
, separator
, prefix
and suffix
.signPosition
.minValue
and maxValue
.BONUS
<FakeCurrencyInput />
: A fake input that hides the real TextInput in order to get rid of the flickering issueformatNumber()
: A function that formats number1npm install react-native-currency-input
or
1yarn add react-native-currency-input
1import CurrencyInput from 'react-native-currency-input'; 2 3function MyComponent() { 4 const [value, setValue] = React.useState(2310.458); // can also be null 5 6 return <CurrencyInput value={value} onChangeValue={setValue} />; 7}
1import CurrencyInput from 'react-native-currency-input'; 2 3function MyComponent() { 4 const [value, setValue] = React.useState(2310.458); 5 6 return ( 7 <CurrencyInput 8 value={value} 9 onChangeValue={setValue} 10 prefix="R$" 11 delimiter="." 12 separator="," 13 precision={2} 14 minValue={0} 15 showPositiveSign 16 onChangeText={(formattedValue) => { 17 console.log(formattedValue); // R$ +2.310,46 18 }} 19 /> 20 ); 21}
1import CurrencyInput from 'react-native-currency-input'; 2import { Input } from 'native-base'; 3 4function MyComponent() { 5 const [value, setValue] = React.useState(2310.458); 6 7 return ( 8 <CurrencyInput 9 value={value} 10 onChangeValue={setValue} 11 renderTextInput={textInputProps => <Input {...textInputProps} variant='filled' />} 12 renderText 13 prefix="R$" 14 delimiter="." 15 separator="," 16 precision={2} 17 /> 18 ); 19}
Prop | Type | Default | Description |
---|---|---|---|
...TextInputProps | Inherit all props of TextInput . | ||
value | number | The value for controlled input. REQUIRED | |
onChangeValue | function | Callback that is called when the input's value changes. REQUIRED | |
prefix | string | Character to be prefixed on the value. | |
suffix * | string | Character to be suffixed on the value. | |
delimiter | string | , | Character for thousands delimiter. |
separator | string | . | Decimal separator character. |
precision | number | 2 | Decimal precision. |
maxValue | number | Max value allowed. Might cause unexpected behavior if you pass a value higher than the one defined here. | |
minValue | number | Min value allowed. Might cause unexpected behavior if you pass a value lower than the one defined here. | |
signPosition | string | "afterPrefix" | Where the negative/positive sign (+/-) should be placed. |
showPositiveSign | boolean | false | Set this to true to show the + character on positive values. |
onChangeText | function | Callback that is called when the input's text changes. IMPORTANT: This does not control the input value, you must use onChangeValue . | |
renderTextInput | function | Use a custom TextInput component. |
* IMPORTANT: Be aware that using the suffix
implies setting the selection
property of the TextInput
internally. You can override the selection
, but that will cause behavior problems on the component
Tip: If you don't want negative values, just use minValue={0}
.
See EXAMPLE
1git clone https://github.com/caioquirinomedeiros/react-native-currency-input.git 2cd react-native-currency-input/example 3yarn 4yarn android / yarn ios
FakeCurrencyInput
This component hides the TextInput
and use a Text
on its place, so you'll lost the cursor, but will get rid of the flickering issue. To replace the cursor it's used a pipe character (|) that will be always at the end of the text. It also have a wrapper View
with position "relative" on which the TextInput
is stretched over.
FakeCurrencyInput
Usage1import { FakeCurrencyInput } from 'react-native-currency-input'; 2 3function MyComponent() { 4 const [value, setValue] = React.useState(0); // can also be null 5 6 return ( 7 <FakeCurrencyInput 8 value={value} 9 onChangeValue={setValue} 10 prefix="$" 11 delimiter="," 12 separator="." 13 precision={2} 14 onChangeText={(formattedValue) => { 15 // ... 16 }} 17 /> 18 ); 19}
FakeCurrencyInput
PropsIt includes the same props of the CurrencyInput with the additional of the following:
Prop | Type | Default | Description |
---|---|---|---|
...CurrencuInputProps | Inherit all props of CurrencyInput . | ||
containerStyle | style prop | Style for the container View that wraps the Text. | |
caretColor | string | #6495ed | Color of the caret. Same as caretStyle.color. |
caretStyle | style prop | Style for the caret text component. |
formatNumber(value, options)
1import { formatNumber } from 'react-native-currency-input'; 2 3const value = -2375923.3; 4 5const formattedValue = formatNumber(value, { 6 separator: ',', 7 prefix: 'R$ ', 8 precision: 2, 9 delimiter: '.', 10 signPosition: 'beforePrefix', 11}); 12 13console.log(formattedValue); // -R$ 2.375.923,30
options
(optional)Name | Type | Default | Description |
---|---|---|---|
prefix | string | Character to be prefixed on the value. | |
suffix | string | Character to be suffixed on the value. | |
delimiter | string | , | Character for thousands delimiter. |
separator | string | . | Decimal separator character. |
precision | number | 2 | Decimal precision. |
ignoreNegative | boolean | false | Set this to true to disable negative values. |
signPosition | string | "afterPrefix" | Where the negative/positive sign (+/-) should be placed. |
showPositiveSign | boolean | false | Set this to true to show the + character on positive values. |
See the contributing guide to learn how to contribute to the repository and the development workflow.
react-native-currency-input is released under the MIT license. See LICENSE for details.
Any question or support will welcome.
No vulnerabilities found.
@dannyhw/react-native-currency-input
fork of react-native-currency-input by Caio Medeiros <caio.quirino.medeiros@gmail.com>
react-native-simple-currency-input
Simple react-native currency input
react-native-currency-input-fields
A simple currency input for React Native
react-native-input-currency
Input component with currency for React Native