logoNamu Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
1.0.0
  • 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

    Namu Design Charts
    Namu Design Pro
    Namu Design Pro Components
    Namu Design Mobile
    Namu Design Mini
    Namu 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 Namu Design
    Medium
    Twitter
    yuqueNamu Design in YuQue
    Namu 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 Namu 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

    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

    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 Token

    Global Token

    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.

    input here


    control mode
    UnClearable


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