Semantic-ui-react: Input Masks

Created on 7 Nov 2016  路  4Comments  路  Source: Semantic-Org/Semantic-UI-React

I'm so sorry if this not right place to ask this question, but does anyone already used masks on Form.Input Class?

question

Most helpful comment

Here's a simple example using text-mask

<Form.Input
  label="Phone"
  name="phone"
  children={
    <MaskedInput
      mask={['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]}
      placeholder="(123) 456-7890"
    />
  }
/>

All 4 comments

I have not tried this but you may be able to use something like the below to either render an <Input as={MaskedInput} /> or wrap them together and use the value of the MaskedInput as the value for the Input:

https://github.com/text-mask/text-mask
https://github.com/sanniassin/react-input-mask

Here's a simple example using text-mask

<Form.Input
  label="Phone"
  name="phone"
  children={
    <MaskedInput
      mask={['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]}
      placeholder="(123) 456-7890"
    />
  }
/>

@ehauzman please use Stack Overflow for usage questions if you are not reporting a bug. It's going to give you much better answers than asking questions on old posts unrelated to the function you are working on.

text-mask doesn't properly work with React Semantic Ui, especially if I want to use icons and similar stuff.
They recommend using ref, but all my attempts didn't reproduced the expected behavior. Sometimes the mask just don't work, or the input doesn't get formatted as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keeslinp picture keeslinp  路  3Comments

eXtreme picture eXtreme  路  3Comments

AlvMF1 picture AlvMF1  路  3Comments

SajagTiwari picture SajagTiwari  路  3Comments

mattmacpherson picture mattmacpherson  路  3Comments