2.10.0
中文
Skip to content

Conversations ​

Used to host the list of historical dialogues sent by the user.

When to use ​

  • Need to manage multiple conversations
  • View the historical conversation list

Examples ​

Basic ​

  • Help Me Write
  • AI Coding
  • Create Image
  • Deep Search
Basic

Basic usage.

Controlled mode ​

  • Help Me Write
  • AI Coding
  • Create Image
  • Deep Search
Controlled mode

Use activeKey and onActiveChange properties to control the currently selected conversation.

Grouped display ​

  • Today
    • This's Conversation Item 1, you can click me!
    • Conversation Item 2
    • Conversation Item 3
  • Yesterday
    • Conversation Item 4
    • Conversation Item 5
    • Conversation Item 6
Grouped display

Use the groupable property to enable grouping. Once enabled, it defaults to grouping by the Conversation.group field.

Collapsible groups ​

  • Today(3)
  • Yesterday(3)
Collapsible groups

Configure the collapsible property to enable collapsibility for groups.

Controlled collapsible groups ​

  • Today
    • Conversation Item 1
    • Conversation Item 4
    • Conversation Item 7
  • Yesterday
  • Historical chats
Controlled collapsible groups

Controlled collapsible groups.

Conversation actions ​

Custom actions ​

  • Conversation Item 1
  • Conversation Item 2
  • Conversation Item 3
  • Conversation Item 4
Custom actions

Custom menu trigger.

New conversation ​

  • Help Me Write
  • AI Coding
  • Create Image
  • Deep Search
  • Today
    • Conversation Item 1
New conversation

Use the creation property to configure the new conversation button.

Custom new conversation ​

  • Help Me Write
  • AI Coding
  • Create Image
  • Deep Search
  • Today
    • Conversation Item 1
Custom new conversation

Customize the new-conversation icon, label, and alignment.

Keyboard shortcuts ​

Switch sessions with Alt/⌥ + number, and create a chat with Win/⌘ + K.
  • Help Me Write
  • AI Coding
  • Create Image
  • Deep Search
  • Today
    • Conversation Item 1
Keyboard shortcuts

Use shortcutKeys to switch conversations or trigger the creation of a new conversation. You can also configure global shortcuts in XProvider under conversations.shortcutKeys.

Infinite scroll ​

Mobile behavior: useMobile is used internally to detect devices. The mobile conversation action menu icon will always be displayed (plus ant-conversations-menu-icon-mobile) and no longer relies on hover.

API ​

ConversationsProps ​

PropertiesDescriptionTypeDefault ValueVersion
activeKeycurrently selected valuestring--
defaultActiveKeyDefault selected valuestring--
itemsSession list data sourceItemType[]--
onActiveChangeSelected change callback(value: string, item?: ItemType) => void--
menuConversation operation menuMenuProps | ((value: ConversationItemType) => MenuProps)--
groupableWhether to support grouping, after enabled, the default grouping is based on the Conversation.group fieldboolean | GroupableProps--
creationConfiguration of new dialog buttonCreationProps-v2
shortcutKeysShortcut keys. creation triggers new creation, items selects sessions in order. Modifier keys are 'Ctrl' | 'Alt' | 'Meta' | 'Shift' and the last key is KeyboardEvent.keyCode or 'number' (numeric keys 1–9){ creation?: ShortcutKeys; items?: ShortcutKeys | ShortcutKeys[] }-v2
stylesSemantic stylesRecord<'root' | 'creation' | 'group' | 'item', CSSProperties>--
classNamesSemantic class namesNameRecord<'root' | 'creation' | 'group' | 'item', string>--
rootClassNameRoot class namestring--

ItemType ​

ItemType = ConversationItemType | DividerItemType

ConversationItemType (Conversation) ​

PropertiesDescriptionTypeDefault ValueVersion
keyunique identifierstring--
labelsession nameVNode | string--
groupConversation grouping type, linked with ConversationsProps.groupablestring--
iconsession iconVNode--
disabledWhether disabledboolean--

DividerItemType ​

PropertiesDescriptionTypeDefault ValueVersion
typeFixed value 'divider''divider'-v2
keyunique identifierstring-v2
dashedWhether to dashboolean-v2

GroupableProps ​

PropertiesDescriptionTypeDefault ValueVersion
labelCustom group label renderingVNode | string | ((group: string, info: { groupInfo }) => VNode)--
collapsibleWhether it is foldableboolean | ((group: string) => boolean)-v2
defaultExpandedKeysInitialize expanded groupsstring[]-v2
expandedKeysCurrently expanded group (controlled)string[]-v2
onExpandExpanded group change callback(expandedKeys: string[]) => void-v2

CreationProps ​

PropertiesDescriptionTypeDefault ValueVersion
labelbutton copy. Function parameters include shortcutKeyInfo and components.CreationLabelVNode | string | ((info) => VNode)Language pack, English New chatv2
iconbutton iconVNode | (() => VNode)PlusOutlinedv2
alignalignment'start' | 'center' | 'end''center'v2
disabledWhether disabledbooleanfalsev2
onClickClick callback(event?: MouseEvent) => void-v2

Inherit antdv MenuProps properties.

PropertiesDescriptionTypeDefault ValueVersion
triggerCustom menu triggerVNode | ((conversation: ConversationItemType, info: { originNode: VNode }) => VNode)--
getPopupContainerMenu rendering parent node(triggerNode: HTMLElement) => HTMLElement--

Semantic DOM ​

  • Help Me Write
  • AI Coding
  • Create Image
  • Deep Search
  • Today
    • Conversation Item 1
    • Conversation Item 2
  • root
    管理对话根节点
  • item
    管理对话子节点
  • creation
    创建对话
  • group
    管理对话分组

Design Token ​

TokenDescriptionTypeDefault value
creationBgColorNew session button background colorstringrgba(primaryColor, 0.15)
creationBorderColorNew session button border colorstringrgba(primaryColor, 0.22)
creationHoverColorNew session button hover background colorstringrgba(primaryColor, 0.25)
shortcutKeyTextColorShortcut key label font colorstringrgba(primaryColor, 0.65)

Contributors ​

Contributors

Loading contributors…