Ask me

logoAnt Design X

DesignDevelopmentComponentsPlayground
  • Overview
  • Common
    • Bubble
    • Conversations
  • Wake
    • Welcome
    • Prompts
  • Express
    • Attachments
    • Sender
    • Suggestion
  • Confirm
    • ThoughtChain
  • Tools
    • useXAgent
    • useXChat
    • XStream
    • XRequest
    • XProvider

Suggestion

A suggestion component for chat.
Import
import{ Suggestion }from"@ant-design/x";
Sourcecomponents/suggestion
Docs
Edit this pageChangelog

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

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

  • Need to build an input box for a dialogue scenario

Examples

API

Common props ref:Common props

suggestionProps

PropertyDescriptionTypeDefaultVersion
blockTake up the full widthbooleanfalse-
childrenCustom input box({ onTrigger, onKeyDown }) => ReactElement--
itemsSuggestion listSuggestionItem[] | ((info: T) => SuggestionItem[])--
openControlled open panelboolean--
rootClassNameRoot element class namestring--
onSelectCallback when the suggestion item is selected(value: string) => void--
onOpenChangeCallback when the panel open state changes(open: boolean) => void--

onTrigger

type onTrigger<T> = (info: T | false) => void;

Suggestion accepts generics to customize the parameter type passed to items renderProps. When false is passed, the suggestion panel is closed.

SuggestionItem

PropertyDescriptionTypeDefaultVersion
childrenChild item for the suggestion itemSuggestionItem[]--
extraExtra content for the suggestion itemReactNode--
iconIcon for the suggestionReactNode--
labelContent to display for the suggestionReactNode--
valueValue of the suggestion itemstring--

Theme Variables (Design Token)

Basic

Basic usage. State management in controlled. Custom trigger.

codepen icon
External Link Icon
expand codeexpand code
Block

Set block to display in a whole row. extra can be used to configure additional information.

codepen icon
External Link Icon
expand codeexpand code
Customize

Dynamically display suggestions with multiple tags based on input.

codepen icon
External Link Icon
expand codeexpand code
 
可任意输入 / 与 # 多次获取建议