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

AutoComplete

Autocomplete function of input field.
가져오기import{ AutoComplete }from"antd";
소스components/auto-complete
문서
이 페이지 수정변경 로그

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 you need an input box instead of a selector.
  • When you need input suggestions or helping text.

The differences with Select are:

  • AutoComplete is an input box with text hints, and users can type freely. The keyword is aiding input.
  • Select is selecting among given choices. The keyword is select.

Examples

API

Common props ref:Common props

PropertyDescriptionTypeDefaultVersion
allowClearShow clear buttonboolean | { clearIcon?: ReactNode }false5.8.0: Support Object type
autoFocusIf get focus when component mountedbooleanfalse
backfillIf backfill selected item the input when using keyboardbooleanfalse
children (for customize input element)Customize input elementHTMLInputElement | HTMLTextAreaElement | React.ReactElement<InputProps><Input />
children (for dataSource)Data source to auto completeReact.ReactElement<OptionProps> | Array<React.ReactElement<OptionProps>>-
defaultActiveFirstOptionWhether active first option by defaultbooleantrue
defaultOpenInitial open state of dropdownboolean-
defaultValueInitial selected optionstring-
disabledWhether disabled selectbooleanfalse
dropdownRenderCustomize dropdown content(menus: ReactNode) => ReactNode-4.24.0
popupClassNameThe className of dropdown menustring-4.23.0
popupMatchSelectWidthDetermine whether the dropdown menu and the select input are the same width. Default set min-width same as input. Will ignore when value less than select width. false will disable virtual scrollboolean | numbertrue
filterOptionIf true, filter options by input, if function, filter options against it. The function will receive two arguments, inputValue and option, if the function returns true, the option will be included in the filtered set; Otherwise, it will be excludedboolean | function(inputValue, option)true
getPopupContainerParent node of the dropdown. Default to body, if you encountered positioning problems during scroll, try changing to the scrollable area and position relative to it. Examplefunction(triggerNode)() => document.body
notFoundContentSpecify content to show when no result matchesReactNode-
openControlled open state of dropdownboolean-
optionsSelect options. Will get better perf than jsx definition{ label, value }[]-
placeholderThe placeholder of inputstring-
statusSet validation status'error' | 'warning'-4.19.0
valueSelected optionstring-
variantVariants of inputoutlined | borderless | filledoutlined5.13.0
onBlurCalled when leaving the componentfunction()-
onChangeCalled when selecting an option or changing an input valuefunction(value)-
onDropdownVisibleChangeCall when dropdown openfunction(open)-
onFocusCalled when entering the componentfunction()-
onSearchCalled when searching itemsfunction(value)-
onSelectCalled when a option is selected. param is option's value and option instancefunction(value, option)-
onClearCalled when clearfunction-4.6.0

Methods

NameDescriptionVersion
blur()Remove focus
focus()Get focus

Design Token

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

토큰 이름설명타입기본값
activeBorderColor激活态边框色string#1677ff
activeOutlineColor激活态 outline 颜色stringrgba(5, 145, 255, 0.1)
clearBg지우기 버튼의 배경색string#ffffff
hoverBorderColor悬浮态边框色string#4096ff
multipleItemBg다중 선택 태그의 배경색stringrgba(0, 0, 0, 0.06)
multipleItemBorderColor다중 선택 태그의 테두리 색상stringtransparent
multipleItemBorderColorDisabled비활성화된 경우 다중 선택 태그의 테두리 색상stringtransparent
multipleItemColorDisabled비활성화된 경우 다중 선택 태그의 텍스트 색상stringrgba(0, 0, 0, 0.25)
multipleItemHeight다중 선택 태그의 높이number24
multipleItemHeightLG큰 크기의 다중 선택 태그의 높이number32
multipleItemHeightSM작은 크기의 다중 선택 태그의 높이number16
multipleSelectorBgDisabled비활성화된 경우 다중 선택기의 배경색stringrgba(0, 0, 0, 0.04)
optionActiveBg옵션이 활성화된 경우 배경색stringrgba(0, 0, 0, 0.04)
optionFontSize옵션의 글꼴 크기number14
optionHeight옵션의 높이number32
optionLineHeight옵션의 줄 높이undefined | LineHeight<string | number>1.5714285714285714
optionPadding옵션의 패딩undefined | Padding<string | number>5px 12px
optionSelectedBg옵션이 선택된 경우 배경색string#e6f4ff
optionSelectedColor옵션이 선택된 경우 텍스트 색상stringrgba(0, 0, 0, 0.88)
optionSelectedFontWeight옵션이 선택된 경우 글꼴 두께undefined | FontWeight600
selectorBg선택기의 배경색string#ffffff
showArrowPaddingInlineEnd화살표의 인라인 끝 패딩number18
singleItemHeightLG큰 크기의 단일 선택된 항목의 높이number40
zIndexPopup드롭다운의 z-indexnumber1050

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

FAQ

Why doesn't the text composition system work well with onSearch in controlled mode?

Please use onChange to manage control state. onSearch is used for searching input which is not the same as onChange. Besides, clicking on the option will not trigger the onSearch event.

Related issue: #18230 #17916

Why won't a controlled open AutoComplete display a drop-down menu when options are empty?

The AutoComplete component is essentially an extension of the Input form element. When the options property is empty, displaying empty text could mislead the user into believing the component is not operational, when in fact they are still able to input text. To avoid confusion, the open property will not display the drop-down menu when set to true and in combination with an empty options property. The open property must be used in conjunction with the options property.

Basic Usage
codepen icon
External Link Icon
expand codeexpand code
Customize Input Component
codepen icon
External Link Icon
expand codeexpand code
Lookup-Patterns - Certain Category
codepen icon
External Link Icon
expand codeexpand code
Status
codepen icon
External Link Icon
expand codeexpand code
Customize clear button
codepen icon
External Link Icon
expand codeexpand code
_InternalPanelDoNotUseOrYouWillBeFired
codepen icon
External Link Icon
expand codeexpand code
Customized
codepen icon
External Link Icon
expand codeexpand code
Non-case-sensitive AutoComplete
codepen icon
External Link Icon
expand codeexpand code
Lookup-Patterns - Uncertain Category
codepen icon
External Link Icon
expand codeexpand code
Variants
codepen icon
External Link Icon
expand codeexpand code
5.13.0
Debug in Form
codepen icon
External Link Icon
expand codeexpand code
input here


control mode
UnClearable


Customized clear icon
input here
try to type `b`
Outlined
Filled
Borderless