Skip to main content

Getting started

Install react-formatted-input-hook using npm:

npm i react-formatted-input-hook

Usage

import { 
useFormattedInput,
currencyFormatter
} from 'react-formatted-input-hook'

const App = () => {
const [value, setValue] = useState<number | null>(null)

const formattedInput = useFormattedInput(
currencyFormatter({
currency: 'EUR',
locales: 'de-DE',
value,
onChange: (value) => setValue(value),
})
)

return <input {...formattedInput.props} />
}

Try interacting with the input to see the formatting in action: