react-formatted-number-input
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

React formatted number input

A higher order component for formatting values in input elements as numbers

Build Status Code Coverage NPM version

Install

$ npm install --save react-formatted-number-input

Usage

import React from 'react';
import { createFormattedNumberInput } from 'react-formatted-number-input';
 
const FancyInput = React.forwardRef((props, ref) => {
  return <div><input ref={ref} {...props} /></div>;
});
 
const FormattedNumberInput = createFormattedNumberInput(FancyInput, { precision: 2 });
 
const Demo = () => {
  const [value, setValue] = React.useState();
 
  return <FormattedNumberInput value={value} onChange={setValue} />;
}

License

MIT © Jonathan Svenheden

Readme

Keywords

none

Package Sidebar

Install

npm i react-formatted-number-input

Weekly Downloads

17

Version

2.0.0

License

MIT

Unpacked Size

76.7 kB

Total Files

20

Last publish

Collaborators

  • jonathanp