# @rc-component/input-number

> React input-number component

Latest version **1.7.0** (published 2026-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rc-component/input-number
pnpm add @rc-component/input-number
yarn add @rc-component/input-number
bun add @rc-component/input-number
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2026-09-08 |
| First published | 2025-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 85.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 323 |
| Author | tsjxyz@gmail.com |
| Maintainers | zombiej, afc163, madccc, peachscript, chenshuai2144 |
| Keywords | react, react-component, react-input-number, input-number |

## Links

- npm: https://www.npmjs.com/package/@rc-component/input-number
- Repository: https://github.com/react-component/input-number
- Homepage: https://react-component.github.io/input-number
- Issues: https://github.com/react-component/input-number/issues
- npm.io page: https://npm.io/package/@rc-component/input-number

## Dependencies (3)

- [clsx](https://npm.io/package/clsx.md) ^2.1.1
- [@rc-component/util](https://npm.io/package/@rc-component/util.md) ^1.13.0
- [@rc-component/mini-decimal](https://npm.io/package/@rc-component/mini-decimal.md) ^1.1.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.7.0 (latest) — 2026-09-08
- 1.6.2 — 2025-11-15
- 1.6.1 — 2025-11-15
- 1.5.1 — 2025-11-10
- 1.6.0 — 2025-11-10
- 1.5.0 — 2025-11-04
- 1.4.1 — 2025-11-03
- 1.4.0 — 2025-11-03
- 1.3.0 — 2025-09-04
- 1.2.0 — 2025-05-16
- 1.1.0 — 2025-04-29
- 1.0.0 — 2025-01-28

## README

<div align="center">
  <h1>@rc-component/input-number</h1>
  <p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
  <p>🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.</p>

  <p>
    <a href="https://npmjs.org/package/@rc-component/input-number"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square"></a>
    <a href="https://npmjs.org/package/@rc-component/input-number"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/input-number.svg?style=flat-square"></a>
    <a href="https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml"><img alt="build status" src="https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml/badge.svg"></a>
    <a href="https://app.codecov.io/gh/react-component/input-number"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/input-number/master.svg?style=flat-square"></a>
    <a href="https://bundlephobia.com/package/@rc-component/input-number"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/input-number?style=flat-square"></a>
    <a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a>
  </p>
</div>

<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>

## Highlights

- Controlled and uncontrolled numeric input modes.
- Decimal precision, custom parser, formatter, and decimal separator support.
- Keyboard stepping, mouse wheel stepping, and custom step handlers.
- Prefix, suffix, spinner controls, and semantic `classNames` / `styles` slots.
- TypeScript generic value typing for number and string based value flows.

## Install

```bash
npm install @rc-component/input-number
```

## Usage

```tsx | pure
import InputNumber from '@rc-component/input-number';

export default () => <InputNumber min={0} max={100} defaultValue={10} />;
```

```tsx | pure
import InputNumber from '@rc-component/input-number';

export default () => (
  <InputNumber
    stringMode
    formatter={(value) => `$ ${value}`}
    parser={(displayValue) => displayValue?.replace(/\$\s?/g, '') || ''}
  />
);
```

## Examples

Run the local dumi site:

```bash
npm install
npm start
```

Then open `http://localhost:8000`.

## API

### InputNumber

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| allowClear | `boolean \| { clearIcon?: ReactNode; disabled?: boolean; label?: string }` | `false` | Show a clear button, optionally with a custom icon, disabled state, or accessible label. |
| autoFocus | `boolean` | `false` | Focus the input when mounted. |
| changeOnBlur | `boolean` | `true` | Commit value changes on blur. |
| changeOnWheel | `boolean` | `false` | Allow value changes from the mouse wheel. |
| className | `string` | - | Class name for the root element. |
| classNames | `Partial<Record<SemanticName, string>>` | - | Semantic class names for input-number slots. |
| controls | `boolean` | `true` | Show increment and decrement controls. |
| decimalSeparator | `string` | - | Decimal separator used by the display formatter. |
| defaultValue | `T` | - | Initial value. |
| disabled | `boolean` | `false` | Disable the input. |
| downHandler | `ReactNode` | - | Custom decrement control. |
| formatter | `(value: T \| undefined, info: { userTyping: boolean; input: string }) => string` | - | Format the displayed value. |
| inputMode | `string` | - | Native input `inputMode` attribute. |
| keyboard | `boolean` | `true` | Enable keyboard stepping. |
| max | `T` | - | Maximum value. |
| min | `T` | - | Minimum value. |
| mode | `'input' \| 'spinner'` | `input` | Render mode. |
| parser | `(displayValue: string \| undefined) => T` | - | Parse the displayed value back to a value. |
| precision | `number` | - | Display precision. |
| prefix | `ReactNode` | - | Prefix content. |
| prefixCls | `string` | `rc-input-number` | Class name prefix. |
| readOnly | `boolean` | `false` | Mark the input as read only. |
| step | `number \| string` | `1` | Step size. |
| stringMode | `boolean` | `false` | Keep values as strings for high precision decimals. |
| style | `React.CSSProperties` | - | Inline styles for the root element. |
| styles | `Partial<Record<SemanticName, React.CSSProperties>>` | - | Semantic styles for input-number slots. |
| suffix | `ReactNode` | - | Suffix content. |
| upHandler | `ReactNode` | - | Custom increment control. |
| value | `T \| null` | - | Controlled value. |
| onChange | `(value: T \| null) => void` | - | Triggered when the committed value changes. |
| onClear | `() => void` | - | Triggered when the clear button is clicked. |
| onInput | `(text: string) => void` | - | Triggered when the raw input text changes. |
| onPressEnter | `React.KeyboardEventHandler<HTMLInputElement>` | - | Triggered when Enter is pressed. |
| onStep | `(value: T, info: { offset: number \| string; type: 'up' \| 'down'; emitter: 'handler' \| 'keyboard' \| 'wheel' }) => void` | - | Triggered when the value changes by step. |

Native input attributes such as `id`, `name`, `placeholder`, `required`, `readOnly`, and `tabIndex` are also supported unless explicitly overridden above.

### Ref

```tsx | pure
import InputNumber, { type InputNumberRef } from '@rc-component/input-number';

const ref = React.useRef<InputNumberRef>(null);

ref.current?.focus();
ref.current?.blur();
```

| Property      | Type                                    | Description          |
| ------------- | --------------------------------------- | -------------------- |
| focus         | `(options?: InputFocusOptions) => void` | Focus the input.     |
| blur          | `() => void`                            | Blur the input.      |
| nativeElement | `HTMLElement`                           | Root native element. |

## Keyboard And Wheel

- Arrow up and Arrow down change the value by `step`.
- `Shift + Arrow` changes the value by `10 * step`.
- `Ctrl` / `Command + Arrow` changes the value by `0.1 * step`.
- Mouse wheel changes are opt-in through `changeOnWheel`.

## Development

```bash
npm install
npm start
npm test
npm run tsc
npm run compile
npm run build
```

The dumi site runs at `http://localhost:8000` by default.

## Release

```bash
npm run prepublishOnly
```

The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build.

## License

@rc-component/input-number is released under the [MIT](./LICENSE) license.

---
_Source: https://npm.io/package/@rc-component/input-number · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
