React-number-format: There is the format usage mode for percentage

Created on 3 May 2017  路  2Comments  路  Source: s-yadav/react-number-format

Hello!

Example:

Obs: Input is the component for create inputs and special management for mask inputs (contains format and anothers props...).

<Input
  type="text"
  label={__("% Ideal de cobertura")}
  id="name"
  name="name"                                                                            
  format={"### %"}                                                                
  required                                                                
  onChange={
  (event) => {
    }
   }
   value="eduardo"
 />

this format result:

budget

Its possible use this component for this?
i need only for number 0-100 with percent format.

Thanks!

Most helpful comment

It would be nice if Percent was supported with this component

All 2 comments

I solve this problem using:

format={
    (val) => {
        if (val <= 100) {
            if (val && val.length > 3)
                return this.state.coverage + " %";
            return val + " %";
        } else {
            return this.state.coverage + " %";
        }
    }
}

It would be nice if Percent was supported with this component

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nourahassan picture nourahassan  路  5Comments

rioarray picture rioarray  路  6Comments

luis-carlos-campos picture luis-carlos-campos  路  3Comments

TkDodo picture TkDodo  路  5Comments

Krakof picture Krakof  路  6Comments