JSPM

  • Created
  • Published
  • Downloads 436246
  • Score
    100M100P100Q171849F
  • License MIT

React input mask

Package Exports

  • react-imask

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-imask) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React IMask Plugin

react-imask

npm version License: MIT

Install

npm install react-imask

Mask Input Example

import {IMaskInput} from 'react-imask';

<IMaskInput
  mask=Number
  radix="."
  value="123"
  unmask="true"
  onAccept={
    // first argument will be `value` or `unmaskedValue` depending on prop above
    (value, mask) => console.log(value)
  }
  // ...and more mask props in a guide

  // input props also available
  placeholder='Enter number here'
/>

Extend Existing Components

import {IMaskMixin} from 'react-imask';

// extend style component
const StyledInput = styled.input`
  color: paleviolet;
`;

const MaskedStyledInput = IMaskMixin(({inputRef, ...props}) => (
  <StyledInput
    ...props
    innerRef={inputRef}  // bind internal input
  />
));

<MaskedStyledInput
  mask=Number
  radix="."
  onAccept={(value, mask) => console.log(value)}
  // ...and more mask props in a guide

  // ...other styled props
/>

More options see in a guide.

Many Thanks to

@Yordis Prieto

@Alexander Kiselev