use-format-amount-input
v0.3.0
Published
Format price, amount input in react
Downloads
7
Maintainers
Readme
useFormatAmountInput
Format amount, price, number fields in react
Installation
yarn add use-format-amount-input
or if npm
is your thing, do:
npm i use-format-amount-input
Usage
import {useFormatAmountInput} from "use-format-amount-input"
const Component = () => {
const {amount, handleAmountChange, strippedAmount} = useFormatAmountInput({decimalPlaces: 3, separator:","})
return <form>
<input type="text" name="amount" value={amount} onChange={handleAmountChange} />
<form>
}
Params
You can pass an optional value to useFormatInput()
which represents the number of decimal places you want to allow the user to be able to enter