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
Controlled mode
- Help Me Write
- AI Coding
- Create Image
- Deep Search
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
Collapsible groups
- Today(3)
- Yesterday(3)
Controlled collapsible groups
- Today
- Conversation Item 1
- Conversation Item 4
- Conversation Item 7
- Yesterday
- Historical chats
Conversation actions
Custom actions
- Conversation Item 1
- Conversation Item 2
- Conversation Item 3
- Conversation Item 4
New conversation
- Help Me Write
- AI Coding
- Create Image
- Deep Search
- Today
- Conversation Item 1
Custom new conversation
- Help Me Write
- AI Coding
- Create Image
- Deep Search
- Today
- Conversation Item 1
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
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
| Properties | Description | Type | Default Value | Version |
|---|---|---|---|---|
| activeKey | currently selected value | string | - | - |
| defaultActiveKey | Default selected value | string | - | - |
| items | Session list data source | ItemType[] | - | - |
| onActiveChange | Selected change callback | (value: string, item?: ItemType) => void | - | - |
| menu | Conversation operation menu | MenuProps | ((value: ConversationItemType) => MenuProps) | - | - |
| groupable | Whether to support grouping, after enabled, the default grouping is based on the Conversation.group field | boolean | GroupableProps | - | - |
| creation | Configuration of new dialog button | CreationProps | - | v2 |
| shortcutKeys | Shortcut 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 |
| styles | Semantic styles | Record<'root' | 'creation' | 'group' | 'item', CSSProperties> | - | - |
| classNames | Semantic class namesName | Record<'root' | 'creation' | 'group' | 'item', string> | - | - |
| rootClassName | Root class name | string | - | - |
ItemType
ItemType = ConversationItemType | DividerItemType
ConversationItemType (Conversation)
| Properties | Description | Type | Default Value | Version |
|---|---|---|---|---|
| key | unique identifier | string | - | - |
| label | session name | VNode | string | - | - |
| group | Conversation grouping type, linked with ConversationsProps.groupable | string | - | - |
| icon | session icon | VNode | - | - |
| disabled | Whether disabled | boolean | - | - |
DividerItemType
| Properties | Description | Type | Default Value | Version |
|---|---|---|---|---|
| type | Fixed value 'divider' | 'divider' | - | v2 |
| key | unique identifier | string | - | v2 |
| dashed | Whether to dash | boolean | - | v2 |
GroupableProps
| Properties | Description | Type | Default Value | Version |
|---|---|---|---|---|
| label | Custom group label rendering | VNode | string | ((group: string, info: { groupInfo }) => VNode) | - | - |
| collapsible | Whether it is foldable | boolean | ((group: string) => boolean) | - | v2 |
| defaultExpandedKeys | Initialize expanded groups | string[] | - | v2 |
| expandedKeys | Currently expanded group (controlled) | string[] | - | v2 |
| onExpand | Expanded group change callback | (expandedKeys: string[]) => void | - | v2 |
CreationProps
| Properties | Description | Type | Default Value | Version |
|---|---|---|---|---|
| label | button copy. Function parameters include shortcutKeyInfo and components.CreationLabel | VNode | string | ((info) => VNode) | Language pack, English New chat | v2 |
| icon | button icon | VNode | (() => VNode) | PlusOutlined | v2 |
| align | alignment | 'start' | 'center' | 'end' | 'center' | v2 |
| disabled | Whether disabled | boolean | false | v2 |
| onClick | Click callback | (event?: MouseEvent) => void | - | v2 |
MenuProps
Inherit antdv MenuProps properties.
| Properties | Description | Type | Default Value | Version |
|---|---|---|---|---|
| trigger | Custom menu trigger | VNode | ((conversation: ConversationItemType, info: { originNode: VNode }) => VNode) | - | - |
| getPopupContainer | Menu 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
| Token | Description | Type | Default value |
|---|---|---|---|
| creationBgColor | New session button background color | string | rgba(primaryColor, 0.15) |
| creationBorderColor | New session button border color | string | rgba(primaryColor, 0.22) |
| creationHoverColor | New session button hover background color | string | rgba(primaryColor, 0.25) |
| shortcutKeyTextColor | Shortcut key label font color | string | rgba(primaryColor, 0.65) |
Contributors
Contributors
Loading contributors…