Skip to content

Allow prefix/suffix and addonBefore/addonAfter on InputNumber just like Input component #14284

@asumaran

Description

@asumaran
  • 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>} />

Metadata

Metadata

Assignees

Labels

Inactivehelp wantedThe suggestion or request has been accepted, we need you to help us by sending a pull request.❓FAQissues would be discussed a lot💡 Feature Request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions