Skip to content

BubbleList Component

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

📌 Warning

Added in version 1.1.6 Inherits the fog effect from the typewriter. Added scroll to bottom button, similar to Doubao🔥. Added scrollbar on mouse hover to enhance interaction experience. Please update and try it out.

🐵 This warm tip was last updated: 2025-04-13

💡 Tip

Note: The new version's auto-scroll will automatically scroll when the list length changes. However, after scrolling up, you need to manually call the scrollToBottom method to re-enable auto-scroll. Or, when the scrollbar reaches the bottom, auto-scroll will be triggered again.

The logic is the same as before, so you can upgrade without any worries.

Introduction

BubbleList relies on the Bubble component and is used to display a list of chat bubbles. This component supports setting the maximum list height and has an auto-scroll feature. It also provides various scroll control methods that users can easily call. It is powerful and requires no mental burden for developers.

Code Examples

Basic Usage

cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
cover

Pre-styled bubble list, quickly create a chat record through a simple Array of messages.

📌 Warning

You can pass properties to the built-in Bubble component through the item property. Set properties for each bubble. More flexible usage. For specific properties, please refer to the Bubble component documentation.

All our message operations only need to maintain this array.

Including streaming message settings. Here we don't use interface streaming operations. In our template project, we go through real combat. You can use it as a reference.

👉 Template Project Preview

👉 Template Project Source Code Welcome to star🥰

You can also control the maximum height of the list through the max-height property.

Customized List

Dynamic content setting
Custom loading
avatar
Element Plus X 🍧
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
avatar
🧁 User
Hahaha, let me try
avatar
Element Plus X 🍧
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
avatar
🧁 User
Hahaha, let me try
avatar
Element Plus X 🍧
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~

🍋 Through #avatar, #header, #content, #loading, #footer slots, you can more flexibly control the rendering of bubble lists

Auto Scroll & Scroll to Specific Position

cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try

🍑 You can easily use bubbleListRef component instance methods to control scrolling to specified index.

🍒 Component Instance Methods

  • scrollToTop():Scroll to top
  • scrollToBottom():Scroll to bottom
  • scrollToBubble(index: number):Scroll to specified index

Back to Top Button

Scrollbar display:
Show on hover
Bottom button loading state:
true
Bottom button color:
Bottom button positionDistance from bottom:
Distance from left:
Bottom button size:
cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
cover
💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~💖 Thank you for using Element Plus X ! Your support is our strongest motivation for open source ~
cover
Hahaha, let me try
  • Built-in back to bottom button, similar to Douyin.
  • Scrollbar appears on mouse hover
  • No conflict with built-in auto-scroll, feel free to use

💌 Info

Scrollbar Control Properties

  • alwaysShowScrollbar property controls whether to always show scrollbar, default is false.

Bottom Button Customization Properties

  • You can set the threshold for the back to bottom button through the backButtonThreshold property, default is 80, meaning the back to bottom button will appear when the scrollbar is 80px away from the bottom.
  • showBackButton property controls whether to show the back to bottom button, default is true.
  • btnLoading property controls whether to show loading state, default is true.
  • btnColor property controls the color of the back to bottom button, default is #409EFF.
  • backButtonPosition property controls the position of the back to bottom button, default is { bottom: '20px', left: 'calc(50% - 19px)' } can use % to control, like { bottom: '10%', left: 'calc(50% - 19px)' }.
  • btnIconSize property controls the icon size of the back to bottom button, default is 24.

Scroll Complete Event

📌 Warning

This is only needed in very special cases. It is not suitable for streaming output, as it will quickly trigger the typing end event.

trigger-indices:

🍉This property is rarely used, please use it judiciously for more fine-grained control over your bubble's completion events in the list.

You can trigger the list through the @complete event, which calls back when each typing Bubble component completes typing. @complete returns two parameters: instance is the typewriter component instance and index is the index of BubbleListItem.

💡 Tip

  • The @complete event will only trigger callback events for Bubble components with typing property set to true.
  • If you configure multiple bubbles with typing property in the list, the list by default only handles the @complete event of the last bubble with typing set to true.

💌 Info

  • If you need to handle completion callback events for multiple bubbles with typing set to true, you can specify the indices of bubbles to handle through the triggerIndices property. It's of type 'only-last' | 'all' | number[].
  • Default is 'only-last', only executes the @complete event of the last bubble with typing set to true.
  • 'all' means execute @complete events for all bubbles with typing set to true. @complete will be executed multiple times.
  • number[] sets the indices of BubbleListItem you want to monitor. The component will automatically filter invalid indices and output console.warn

Props

NameType
Required
DefaultDescription
listArrayYesNoneArray containing bubble information. Each element is an object with content, placement, loading, shape, variant, isMarkdown, typing, and other Bubble properties to configure the display and style of each bubble.
autoScrollBooleanNotrueWhether to enable automatic scrolling.
maxHeightStringNo'-'Maximum height of the bubble list container.(By default, the height of the wrapper container is inherited)
alwaysShowScrollbarBooleanNofalseWhether to always show the scrollbar. Default is false.
backButtonThresholdNumberNo80Back to bottom button display threshold. When the scrollbar is more than this distance from the bottom, the button will be shown.
showBackButtonBooleanNotrueWhether to show the back to bottom button. Default is true.
backButtonPosition{ bottom: '20px', left: 'calc(50% - 19px)' }No{ bottom: '20px', left: 'calc(50% - 19px)' }Position of the back to bottom button. Default is centered at the bottom.
btnLoadingBooleanNotrueWhether to enable loading state for the back to bottom button. Default is true.
btnColorStringNo'#409EFF'Color of the back to bottom button. Default is '#409EFF'.
btnIconSizeNumberNo24Icon size of the back to bottom button. Default is 24px.
triggerIndices'only-last' | 'all' | number[]No'only-last'Index array of bubbles that trigger the complete event. Default is 'only-last'.

Events

Event NameParameterTypeDescription
@complete(instance, index)FunctionTriggered when the typing effect of a bubble is completed.

Ref Instance Methods

NameTypeDescription
scrollToTopFunctionScroll to the top.
scrollToBottomFunctionScroll to the bottom.
scrollToBubbleFunctionScroll to the specified bubble index.

Slots

Slot NameParameterTypeDescription
#avatar-SlotCustom avatar display content
#header-SlotCustom bubble header content
#content-SlotCustom bubble content
#loading-SlotCustom bubble loading state content
#footer-SlotCustom bubble footer content

Features

  1. Smart Scrolling - Automatically tracks the latest message position
  2. Deep Customization - Full slot passthrough for bubble components
  3. Multiple Scrolling Methods - Scroll to top, bottom, or specific position
  4. Typing Effect - Supports typing effect
  5. Multiple Styles - Supports various styles such as round, square, etc.