-
-
Notifications
You must be signed in to change notification settings - Fork 53.5k
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
What problem does this feature solve?
I was working on a custom input that formats the entered data into monetary value.
Something like: 9876.12
=> 9,876.12
and also wanted to add a $
prefix into the input without being part of the input value.
I noticed we can do that with the Input
component but in order to format the entered value to the format I wanted I realized it was not going to be as easy as InputNumber
with formatter
and parser
props.
I ended up wrapping up an InputNumber
into another component which accepts all the same props as InputNumber
plus the prefix
option and made it look exactly as Input
.
The render method looks something like
render() {
const { prefix, ...inputNumberProps } = this.props;
return (
<span className="my-custom-component">
<span className="prefix">{prefix}</span>
<InputNumber {...inputNumberProps} />
</span>
);
}
I think it would be useful if InputNumber
accepts a prefix
prop for cases like this.
What does the proposed API look like?
The use and result should be exactly as Input
.
<InputNumber prefix="$" />
<InputNumber prefix={<span>$</span>} />