logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
5.9.2
  • Components Overview
  • General
    • Button
    • FloatButtonNew
    • Icon
    • Typography
  • Layout
    • Divider
    • Grid
    • Layout
    • Space
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPickerNew
    • 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
    • QRCodeNew
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • TourNew
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • AppNew
    • ConfigProvider
When To Use
Examples
Basic Usage
Customized
Customize Input Component
Non-case-sensitive AutoComplete
Lookup-Patterns - Certain Category
Lookup-Patterns - Uncertain Category
Status
Borderless
Customize clear button
API
Methods
Design Token
FAQ
Why doesn't the text composition system work well with onSearch in controlled mode?
Why won't a controlled open AutoComplete display a drop-down menu when options are empty?

AutoComplete

  • StepsCascader

    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
    yuqueAnt Design in YuQue
    Ant Design in Zhihu
    Experience Cloud Blog
    seeconfSEE Conf-Experience Tech Conference

    Help

    GitHub
    Change Log
    FAQ
    Bug Report
    Issues
    Discussions
    StackOverflow
    SegmentFault

    Ant XTechMore Products

    yuqueYuQue-Document Collaboration Platform
    AntVAntV-Data Visualization
    EggEgg-Enterprise Node.js Framework
    kitchenKitchen-Sketch Toolkit
    xtechAnt Financial Experience Tech
    Theme Editor
    Made with ❤ by
    Ant Group and Ant Design Community

    Autocomplete function of input field.

    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
    borderedWhether has border stylebooleantrue
    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
    popupClassNameThe className of dropdown menustring-4.23.0
    dropdownMatchSelectWidthDetermine 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
    notFoundContentSpecify content to show when no result matchesstringNot Found
    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-
    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

    Component TokenHow to use?

    Token NameDescriptionTypeDefault Value
    clearBgBackground color of clear buttonstring#ffffff
    multipleItemBgBackground color of multiple tagstringrgba(0, 0, 0, 0.06)
    multipleItemBorderColorBorder color of multiple tagstringtransparent
    multipleItemBorderColorDisabledBorder color of multiple tag when disabledstringtransparent
    multipleItemColorDisabledText color of multiple tag when disabledstringrgba(0, 0, 0, 0.25)
    multipleItemHeightHeight of multiple tagnumber24
    multipleItemHeightLGHeight of multiple tag with large sizenumber32
    multipleSelectorBgDisabledBackground color of multiple selector when disabledstringrgba(0, 0, 0, 0.04)
    optionActiveBgBackground color when option is activestringrgba(0, 0, 0, 0.04)
    optionFontSizeFont size of optionnumber14
    optionHeightHeight of optionnumber32
    optionLineHeightLine height of optionundefined | LineHeight<string | number>1.5714285714285714
    optionPaddingPadding of optionundefined | Padding<string | number>5px 12px
    optionSelectedBgBackground color when option is selectedstring#e6f4ff
    optionSelectedColorText color when option is selectedstringrgba(0, 0, 0, 0.88)
    optionSelectedFontWeightFont weight when option is selectedundefined | FontWeight600
    selectorBgBackground color of selectorstring#ffffff
    singleItemHeightLGHeight of single selected item with large sizenumber40
    zIndexPopupz-index of dropdownnumber1050

    Global TokenHow to use?

    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

    Basic Usage, set data source of autocomplete with options property.

    expand codeexpand code
    Customize Input Component

    Customize Input Component

    expand codeexpand code
    Lookup-Patterns - Certain Category

    Demonstration of Lookup Patterns: Certain Category. Basic Usage, set options of autocomplete with options property.

    expand codeexpand code
    Status

    Add status to AutoComplete with status, which could be error or warning.

    expand codeexpand code
    Customize clear button

    Customize clear button

    expand codeexpand code
    Customized

    You could set custom Option label

    expand codeexpand code
    Non-case-sensitive AutoComplete

    A non-case-sensitive AutoComplete

    expand codeexpand code
    Lookup-Patterns - Uncertain Category

    Demonstration of Lookup Patterns: Uncertain Category.

    expand codeexpand code
    Borderless

    No border.

    expand codeexpand code
    input here


    control mode
    UnClearable


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