Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Yefet committed Oct 4, 2021
1 parent c498b29 commit 1cca5ea
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ A super simple input component that formats as you type.

![Formatted input](https://raw.githubusercontent.com/danielyefet/react-input-auto-format/main/images/input.gif)

## Quick start
## Quickstart

Install it...
Install it:

```sh
npm install react-input-auto-format
Expand All @@ -26,23 +26,22 @@ function Foo () {
}
```

The `format` prop accepts a pattern. The `#` character represents any number or letter. You can put whatever else you like in there.
The `format` prop accepts a pattern. The `#` character represents any number or letter, and you can put whatever else you like in there.

### Examples:

| Pattern | Result |
| ------------------ | ------------ |
| \#\# / \#\# | 12 / 34 |
| \#\# - \#\# - \#\# | 12 - 34 - 56 |
| \#\#\#\# \#\#\# | LM68 XKC |
| Style | Pattern | Result |
| ------------ | ------------------ | ------------ |
| Expiry date | \#\# / \#\# | 12 / 34 |
| Sort code | \#\# - \#\# - \#\# | 12 - 34 - 56 |
| Number plate | \#\#\#\# \#\#\# | LM68 XKC |

## Getting the raw value

To get the unformatted value, use the `onValueChange` prop.

```JSX
function Foo () {

handleValueChange(value) {
console.log(value); // 123456
}
Expand All @@ -56,4 +55,4 @@ function Foo () {

## Everything else

All other props work the same as you would expect for a native input component. If you want the formatted value, use a normal `onChange` attribute and pull out `event.target.value`.
All other props work the same as you would expect for a native input component. If you want the formatted value, use a standard `onChange` attribute and pull out `event.target.value`.

0 comments on commit 1cca5ea

Please sign in to comment.