logoAnt Design

⌘ K
  • 디자인
  • 개발
  • 컴포넌트
  • 블로그
  • 자료
5.21.3
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
      5.13.0

InputNumber

Enter a number within certain range with the mouse or keyboard.
가져오기import{ InputNumber }from"antd";
소스components/input-number
문서
이 페이지 수정변경 로그

Resources

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
ahooks-React Hooks Library
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference
Work with Us

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

When To Use

When a numeric value needs to be provided.

Examples

API

Common props ref:Common props

PropertyDescriptionTypeDefaultVersion
addonAfterThe label text displayed after (on the right side of) the input fieldReactNode-
addonBeforeThe label text displayed before (on the left side of) the input fieldReactNode-
autoFocusIf get focus when component mountedbooleanfalse-
changeOnBlurTrigger onChange when blur. e.g. reset value in range by blurbooleantrue5.11.0
changeOnWheelAllow control with mouse wheelboolean-5.14.0
controlsWhether to show +- controls, or set custom arrows iconboolean | { upIcon?: React.ReactNode; downIcon?: React.ReactNode; }-4.19.0
decimalSeparatorDecimal separatorstring--
placeholderplaceholderstring-
defaultValueThe initial valuenumber--
disabledIf disable the inputbooleanfalse-
formatterSpecifies the format of the value presentedfunction(value: number | string, info: { userTyping: boolean, input: string }): string-info: 4.17.0
keyboardIf enable keyboard behaviorbooleantrue4.12.0
maxThe max valuenumberNumber.MAX_SAFE_INTEGER-
minThe min valuenumberNumber.MIN_SAFE_INTEGER-
parserSpecifies the value extracted from formatterfunction(string): number--
precisionThe precision of input value. Will use formatter when config of formatternumber--
readOnlyIf readonly the inputbooleanfalse-
statusSet validation status'error' | 'warning'-4.19.0
prefixThe prefix icon for the InputReactNode-4.17.0
suffixThe suffix icon for the InputReactNode-5.20.0
sizeThe height of input boxlarge | middle | small--
stepThe number to which the current value is increased or decreased. It can be an integer or decimalnumber | string1-
stringModeSet value as string to support high precision decimals. Will return string value by onChangebooleanfalse4.13.0
valueThe current valuenumber--
variantVariants of Inputoutlined | borderless | filledoutlined5.13.0
onChangeThe callback triggered when the value is changedfunction(value: number | string | null)--
onPressEnterThe callback function that is triggered when Enter key is pressedfunction(e)--
onStepThe callback function that is triggered when click up or down buttons(value: number, info: { offset: number, type: 'up' | 'down' }) => void-4.7.0

Ref

NameDescriptionVersion
blur()Remove focus
focus()Get focus
nativeElementThe native DOM element5.17.3

Design Token

컴포넌트 토큰어떻게 사용하나요?

토큰 이름설명타입기본값
activeBg输入框激活状态时背景颜色string#ffffff
activeBorderColor激活态边框色string#1677ff
activeShadow激活态阴影string0 0 0 2px rgba(5, 145, 255, 0.1)
addonBg前/后置标签背景色stringrgba(0, 0, 0, 0.02)
controlWidth输入框宽度number90
errorActiveShadow错误状态时激活态阴影string0 0 0 2px rgba(255, 38, 5, 0.06)
filledHandleBg面性变体操作按钮背景色string#f0f0f0
handleActiveBg操作按钮激活背景色stringrgba(0, 0, 0, 0.02)
handleBg操作按钮背景色string#ffffff
handleBorderColor操作按钮边框颜色string#d9d9d9
handleFontSize操作按钮图标大小number7
handleHoverColor操作按钮悬浮颜色string#1677ff
handleVisible操作按钮可见性true | "auto"auto
handleWidth操作按钮宽度number22
hoverBg输入框hover状态时背景颜色string#ffffff
hoverBorderColor悬浮态边框色string#4096ff
inputFontSize字体大小number14
inputFontSizeLG大号字体大小number16
inputFontSizeSM小号字体大小number14
paddingBlock输入框纵向内边距number4
paddingBlockLG大号输入框纵向内边距number7
paddingBlockSM小号输入框纵向内边距number0
paddingInline输入框横向内边距number11
paddingInlineLG大号输入框横向内边距number11
paddingInlineSM小号输入框横向内边距number7
warningActiveShadow警告状态时激活态阴影string0 0 0 2px rgba(255, 215, 5, 0.1)

글로벌 토큰어떻게 사용하나요?

Notes

Per issues #21158, #17344, #9421, and documentation about inputs, it appears this community does not support native inclusion of the type="number" in the <Input /> attributes, so please feel free to include it as needed, and be aware that it is heavily suggested that server side validation be utilized, as client side validation can be edited by power users.

FAQ

Why value can exceed min or max in control?

Developer handle data by their own in control. It will make data out of sync if InputNumber change display value. It also cause potential data issues when use in form.

Why dynamic change min or max which makes value out of range will not trigger onChange?

onChange is user trigger event. Auto trigger will makes form lib can not detect data modify source.

Why onBlur or other event can not get correct value?

InputNumber's value is wrapped by internal logic. The event.target.value you get from onBlur or other event is the DOM element's value instead of the actual value of InputNumber. For example, if you change the display format through formatter or decimalSeparator, you will get the formatted string in the DOM. You should always get the current value through onChange.

Why changeOnWheel unable to control whether the mouse scroll wheel changes value?

The use of the type attribute is deprecated

The InputNumber component allows you to use all the attributes of the input element and ultimately pass them to the input element, This attribute will also be added to the input element when you pass in type='number', which will cause the input element to trigger native properties (allowing the mouse wheel to change the value), As a result changeOnWheel cannot control whether the mouse wheel changes the value.

Basic
codepen icon
External Link Icon
expand codeexpand code
Pre / Post tab
codepen icon
External Link Icon
expand codeexpand code
High precision decimals
codepen icon
External Link Icon
expand codeexpand code
Keyboard
codepen icon
External Link Icon
expand codeexpand code
Variants
codepen icon
External Link Icon
expand codeexpand code
5.13.0
Out of range
codepen icon
External Link Icon
expand codeexpand code
Status
codepen icon
External Link Icon
expand codeexpand code
_InternalPanelDoNotUseOrYouWillBeFired
codepen icon
External Link Icon
expand codeexpand code
Sizes
codepen icon
External Link Icon
expand codeexpand code
Disabled
codepen icon
External Link Icon
expand codeexpand code
Formatter
codepen icon
External Link Icon
expand codeexpand code
Wheel
codepen icon
External Link Icon
expand codeexpand code
5.14.0
Filled Debug
codepen icon
External Link Icon
expand codeexpand code
Prefix / Suffix
codepen icon
External Link Icon
expand codeexpand code
Icon
codepen icon
External Link Icon
expand codeexpand code
Override Component Style
codepen icon
External Link Icon
expand codeexpand code
+
$
+
$
cascader
+
+
¥
$
$
$
http://
.com
http://
.com
http://
.com
.com
.com
.com
http://
http://
http://
¥


¥


¥


RMB
$