Skip to content

Conversations Component

使用import { Conversations } from 'vue-element-plus-x'

Introduction

Conversations is a session management component developed based on Vue 3 and Element Plus, supporting grouped display, menu interaction, scroll loading, custom styles and other features. Suitable for message lists, file management, task grouping and other scenarios, it meets diverse business needs through flexible configuration and slot extensions.

Code Examples

Basic Usage

  • Today's Session 111111111111111111111111111
  • Today's Session 2
  • Yesterday's Session 1
  • Yesterday's Session 2
  • Session from a week ago
  • Session from a month ago
  • Session from long ago

Get selected session information through @change event. v-model:active binds the currently selected session.

Time Grouping and Sticky Effect

  • today
  • Today's Session 111111111111111111111111111
  • Today's Session 2
yesterday
  • Yesterday's Session 1
  • 未分组
  • Yesterday's Session 2
  • Session from a week ago
  • Session from a month ago
  • Session from long ago
  • Time Grouping and Sticky Effect

    Automatically groups by the group field of session items, group titles stick to top when scrolling, enhancing navigation experience.

    Custom Group Sorting

    • 📚 Study
    • Study Notes 1
    • Study Notes 2
    📊 Work
  • Work Document 1
  • Work Document 11111111111111111111111111111111111111111
  • Work Document 3
  • Work Document 4
  • Work Document 5
  • Work Document 6
  • 🏠 Personal
  • Personal Document 1
  • 📁 未分组
  • Ungrouped Item
  • Pass sorting function through groupable property to customize group order (e.g.: Study > Work > Personal > Ungrouped).

    Built-in Dropdown Menu

    • Menu Test Item 1 - Long text effect demonstration text length overflow effect testMenu Test Item 1 - Long text effect demonstration text length overflow effect test
    • Menu Test Item 2
    • Menu Test Item 3
    • Menu Test Item 4
    • Menu Test Item 5
    • Menu Test Item 6
    • Menu Test Item 7
    • Menu Test Item 8
    • Menu Test Item 9
    • Menu Test Item 10
    • Menu Test Item 11
    • Menu Test Item 12
    • Menu Test Item 13
    • Menu Test Item 14

    Built-in basic menu functionality (rename, delete), supports menu command callbacks, easily implements quick operations for session items.

    @menu-command triggers built-in menu click events.

    Built-in Dropdown Menu Button Type

    • Menu Test Item 1 - Long Text Effect Demo Text Length Overflow Effect TestMenu Test Item 1 - Long Text Effect Demo Text Length Overflow Effect Test
    • Menu Test Item 2
    • Menu Test Item 3
    • Menu Test Item 4
    • Menu Test Item 5
    • Menu Test Item 6
    • Menu Test Item 7
    • Menu Test Item 8
    • Menu Test Item 9
    • Menu Test Item 10
    • Menu Test Item 11
    • Menu Test Item 12
    • Menu Test Item 13
    • Menu Test Item 14

    Use the showBuiltInMenuType property to set whether to always display the built-in menu button.

    The optional values for the showBuiltInMenuType property are:

    • hover: Show built-in menu button on mouse hover (default)
    • always: Always show built-in menu button

    Custom Menu Interaction

    • Menu Test Item 1 - Long text effect demonstration text length overflow effect testMenu Test Item 1 - Long text effect demonstration text length overflow effect test
    • Menu Test Item 2
    • Menu Test Item 3
    • Menu Test Item 4
    • Menu Test Item 5
    • Menu Test Item 6
    • Menu Test Item 7
    • Menu Test Item 8
    • Menu Test Item 9
    • Menu Test Item 10
    • Menu Test Item 11
    • Menu Test Item 12
    • Menu Test Item 13
    • Menu Test Item 14

    Extend menu content through slots, supports icons, text and custom commands, meets complex business logic.

    Lazy Loading Feature

    • Initial Item 1
    • Initial Item 2
    • Initial Item 3
    • Initial Item 1
    • Initial Item 2
    • Initial Item 3
    • Initial Item 1
    • Initial Item 2
    • Initial Item 3

    Automatically triggers loading more data when scrolling to bottom, supports loading state display, optimizes performance for large data scenarios.

    Custom Styles and Group Titles

    • 📚 Study
    • Menu Test Item 4
    • Menu Test Item 5
    • Menu Test Item 6
    • Menu Test Item 7
    📊 Work
  • Menu Test Item 1 - Long text effect demonstration text length overflow effect testMenu Test Item 1 - Long text effect demonstration text length overflow effect test
  • Menu Test Item 2
  • Menu Test Item 3
  • 🏠 Personal
  • Menu Test Item 8
  • Menu Test Item 9
  • Menu Test Item 10
  • Menu Test Item 11
  • 📁 未分组
  • Menu Test Item 12
  • Menu Test Item 13
  • Menu Test Item 14
  • Customize session item appearance and group title icons through slots and style properties, supports hover, active, menu opened state style customization.

    Properties

    Property NameTypeRequiredDefaultDescription
    itemsConversationItem<T>[]No[]Session item data list, containing label, group, disabled and other fields
    groupableboolean | GroupableOptionsNofalseWhether to enable grouping, passing object can customize group sorting (sort function)
    showBuiltInMenubooleanNofalseWhether to show built-in menu (rename, delete)
    loadMore() => voidNo-Lazy loading callback function, triggered when scrolling to bottom
    loadMoreLoadingbooleanNofalseLoad more state, controls loading animation display
    showToTopBtnbooleanNofalseWhether to show back to top button
    labelKeystringNo'label'Session item label field name
    rowKeystringNo'id'Session item unique identifier field name
    itemsStyleCSSPropertiesNo{}Session item default style
    itemsHoverStyleCSSPropertiesNo{}Session item hover style
    itemsActiveStyleCSSPropertiesNo{}Session item active style
    itemsMenuOpenedStyleCSSPropertiesNo{}Session item style when menu is opened

    Slots

    Slot NameParametersDescription
    #groupTitle{ group: GroupItem }Custom group title, supports adding icons or special styles
    #label{ item: ConversationItem<T> }Custom session item label content, supports text overflow handling or rich text
    #more-filled{ item, isHovered, isActive, isMenuOpened, isDisabled }Session item right side additional content, displays status indicators (e.g.: disabled mark, action icons)
    #menu{ item: ConversationItem<T>, handleOpen, handleClose }Custom menu content, supports buttons, icons or complex interactive components,handleOpenused to control the opening of the drop-down menu, handleCloseused to control the closing of drop-down menus.
    #header-Container header slot, for adding search bars, filter buttons and other custom content
    #footer-Container footer slot, for adding pagination, statistics and other custom content

    Events

    EventParametersDescription
    @menuCommand(command: ConversationMenuCommand, item: ConversationItem): voidMenu command callback, supports rename, delete and other operations. If you choose custom menu, this method is disabled, you need to handle menu click logic yourself.
    :loadMore--Bind lazy loading callback, triggered when scrolling to bottom

    Features

    1. Flexible Group Management
    1. Rich Interaction Support
    1. Performance Optimization
    1. Highly Customizable