# react-formatted-input

> A component for formatting input data on the fly

Latest version **0.3.0** (published 2018-11-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-formatted-input
pnpm add react-formatted-input
yarn add react-formatted-input
bun add react-formatted-input
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2018-11-16 |
| First published | 2016-09-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 214.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | everdimension |
| Maintainers | everdimension |
| Keywords | react, react-component, masked input, formatted input, parse |

## Links

- npm: https://www.npmjs.com/package/react-formatted-input
- Repository: https://github.com/everdimension/react-formatted-input
- Homepage: https://github.com/everdimension/react-formatted-input#readme
- Issues: https://github.com/everdimension/react-formatted-input/issues
- npm.io page: https://npm.io/package/react-formatted-input

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.16.6

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2018-11-16
- 0.2.2 — 2018-11-16
- 0.2.1 — 2018-04-22
- 0.2.0 — 2017-11-17
- 0.1.0 — 2017-06-02
- 0.0.15 — 2017-05-11
- 0.0.14 — 2016-12-29
- 0.0.13 — 2016-12-27
- 0.0.12 — 2016-12-03
- 0.0.11 — 2016-12-03
- 0.0.10 — 2016-11-16
- 0.0.9 — 2016-11-15
- 0.0.8 — 2016-11-14
- 0.0.7 — 2016-11-12
- 0.0.6 — 2016-09-13
- … 5 more at https://npm.io/package/react-formatted-input/versions

## README

A react component for formatting input text based on the provided formatter
function.

### Usage

A simple input which adds commas as a thousands separator:

```javascript
function addThousandsSeparator(str = '') {
  return str.split('').reverse().map((l, i) => {
    if (i && i % 3 === 0) {
      return `${l},`;
    }
    return l;
  })
    .reverse()
    .join('');
}

function removeThousandsSeparator(str = '') {
  return str.replace(/\D/g, '');
}

function ThousandsSeparator() {
  return (
    <FormattedInput
      type="text"
      getFormattedValue={addThousandsSeparator}
      getUnformattedValue={removeThousandsSeparator}
      defaultValue="1234"
    />
  );
}
```

---
_Source: https://npm.io/package/react-formatted-input · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
