Skip to content

BubbleList

使用import { BubbleList } from 'vue-element-plus-x'
文档
Edit this pageChangelogFeedback

📌 Warning

Added in version 1.1.6 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
💖 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 ~

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.

cover
💖 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 ~
cover
Hahaha, let me try
cover
💖 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 ~

This event is triggered when the BubbleList list rendering is complete.

💌 Info

  • The @complete event returns an index parameter, indicating the index of the completed BubbleListItem.
  • Starting from v2.0.0, the triggerIndices property and TypewriterInstance parameter have been removed.

Theme Overrides (themeOverrides)

Override BubbleList theme tokens via ConfigProvider.themeOverrides. See the full token list and template:

Scroll the list to see size changes.
Message 1: used to demonstrate scrolling and the back button.
Message 2: used to demonstrate scrolling and the back button.
Message 3: used to demonstrate scrolling and the back button.
Message 4: used to demonstrate scrolling and the back button.
Message 5: used to demonstrate scrolling and the back button.
Message 6: used to demonstrate scrolling and the back button.
Message 7: used to demonstrate scrolling and the back button.
Message 8: used to demonstrate scrolling and the back button.
Message 9: used to demonstrate scrolling and the back button.
Message 10: used to demonstrate scrolling and the back button.
Message 11: used to demonstrate scrolling and the back button.
Message 12: used to demonstrate scrolling and the back button.
Message 13: used to demonstrate scrolling and the back button.
Message 14: used to demonstrate scrolling and the back button.
Message 15: used to demonstrate scrolling and the back button.
Message 16: used to demonstrate scrolling and the back button.
Message 17: used to demonstrate scrolling and the back button.
Message 18: used to demonstrate scrolling and the back button.

Override BubbleList --elx-* variables via ConfigProvider.themeOverrides and also style Bubble for a stronger contrast.

Using with x-markdown-vue

Starting from v2.0.0, the component library no longer bundles XMarkdown / XMarkdownAsync. For Markdown rendering, use x-markdown-vue or see the dedicated page: XMarkdown.

Installation

bash
pnpm add x-markdown-vue
pnpm add katex
pnpm add shiki shiki-stream

💡 Tip

If you need code block syntax highlighting, please install shiki and shiki-stream. Otherwise, you may see this error in the console: Streaming highlighter initialization failed: Error: Failed to load shiki-stream module

Basic Usage

cover
cover
cover

Supports formulas, code blocks, and task lists in list rendering.

Streaming Rendering

By setting the enable-animate property, you can achieve a typewriter effect:

vue
<template>
  <BubbleList :list="list">
    <template #content="{ item }">
      <MarkdownRenderer :markdown="item.content" :enable-animate="true" />
    </template>
  </BubbleList>
</template>

<script setup>
import { ref } from 'vue';
import { BubbleList } from 'vue-element-plus-x';
import { MarkdownRenderer } from 'x-markdown-vue';
import 'x-markdown-vue/style';

const list = ref([
  { content: '', placement: 'start' } // Streaming content will be updated dynamically
]);
</script>

Props

NameType
Required
DefaultDescription
listArrayYesNoneArray containing bubble information. Each element is an object with content, placement, loading, shape, variant, and other Bubble properties to configure the display and style of each bubble. For Markdown, render via the #content slot.
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. Multiple Styles - Supports various styles such as round, square, etc.