Skip to content

Bubble Chat Bubble ๐Ÿ”ฅ โ€‹

๐Ÿ“Œ Warning

Version 1.1.6 inherits the typewriter's fog effect. Please update to try it out.

๐Ÿต Last updated: 2025-04-13

Introduction โ€‹

Bubble is a chat bubble component, commonly used in chat scenarios. It can display conversation content, supports custom avatars, headers, content, footers, and has typing effects and loading state display. The component has built-in Typewriter component that can achieve text typing animation effects.

Code Examples โ€‹

Basic Usage โ€‹

hello world !

Simplest integration method.

Avatar and Placement โ€‹

cover
Good morning, how are you?
What a beautiful day!
Hi, good morning, I'm fine!
Hi, good morning, I'm fine! Thank you!

Set custom avatar through #avatar. Set position through placement property, provides start, end two option values.

๐Ÿ’ก Tip

๐Ÿ˜ธ Built-in element-plus el-avatar component. But to avoid property name conflicts, for example: el-avatar and Bubble's shape property. You need to use the following properties to set

  1. Properties
  • avatar Set avatar placeholder image
  • avatar-size Set avatar placeholder size ๐Ÿ‘‰This property is number type in el-avatar component, note that in this component it's string type for better custom style properties๐Ÿ˜Š
  • avatar-gap Set distance between avatar and bubble
  • avatar-shape Set avatar shape
  • avatar-icon Set avatar placeholder icon
  • avatar-src-set Set avatar image srcset attribute
  • avatar-alt Set avatar image alt attribute
  • avatar-fit Set avatar placeholder image fill mode
  1. Events
  • @avatar-error Triggered when avatar loading fails.

Loading State โ€‹

loading...
Thank you for using Element-Plus-X ๐ŸŒน Please wait...
State:

Set loading state through loading property. Supports custom loading state content display through #loading slot.

๐Ÿ’Œ Info

#loading slot has higher priority, built-in loading styles will be disabled. But the loading property can still control the loading state.

Typewriter Configuration โ€‹

Enable typing effect by setting the typing property. When updating content, if it's a subset of the previous content, it will continue outputting, otherwise it will restart.

๐Ÿ’Œ Info

๐Ÿ™Š When using #content slot to customize content, the typing property will be disabled. If you want to re-implement typing effect for your content string, you can combine it with the Typewriter component.

๐Ÿ’ก Tip

The typing property accepts an object with the following properties:

  • step: Number of characters typed each time, default is 2
  • interval: Typing interval (milliseconds), default is 50
  • suffix: Ending character, default is |

Enable Markdown Rendering โ€‹

Enable markdown text content rendering mode by setting the is-markdown property. When updating content, if it's a subset of the previous content, it will continue outputting, otherwise it will restart.

Inherit Typewriter Charts and MD Styles โ€‹

Enable markdown text content rendering mode by setting the is-markdown property. When updating content, if it's a subset of the previous content, it will continue outputting, otherwise it will restart.

Fog Effect โ€‹

When typewriter is enabled, inherits the typewriter's fog property. Enable fog typewriter rendering mode by setting the is-fog property. Compatible with Markdown styles. Note that after enabling fog, the typing suffix suffix property will be disabled.

is-fog defaults to false, can be set to true or { bgColor: '#f5f5f5', width: '80px' }. Setting fog background color can better match custom styles.

Custom Content โ€‹

cover
๐Ÿ˜Š Welcome to element-plus-x, I'm a custom bubble
Recommended Content Custom Bubble
๐Ÿฅค How to rest effectively after long hours of work?
๐Ÿ’Œ What's the secret to maintaining a positive mindset?
๐Ÿ”ฅ How to stay calm under tremendous pressure?

Customize bubble content through #content slot.

๐Ÿ’Œ Info

#content slot has higher priority, content property will be disabled. no-padding property can disable bubble content padding.

Variants and Shapes โ€‹

filled
filled + round
filled + corner
borderless
borderless + round
borderless + corner
outlined
outlined + round
outlined + corner
shadow
shadow + round
shadow + corner
round
corner
placement end

Set bubble's built-in style format through variant property. Set bubble's shape through shape property. Of course you can also combine them and use them together.

๐Ÿ’Œ Info

By default, variant is filled, shape is round.

When shape is corner, placement="end" will automatically flip the bubble so that the top-right corner radius pointer points to the user.

Control Typing โ€‹

๐Ÿ’ฉ Better control over interrupt output, continue typing and destroy operations

๐Ÿ’ก Tip

๐Ÿ˜ธ Built-in Typewriter component. Mounts all properties and methods from the Typewriter component to the Bubble component for convenient use in agile development.

๐Ÿ’Œ Info

๐Ÿ’ If you feel the built-in Typewriter component doesn't meet your needs, you can also use the #content slot for customized development of the Bubble component. Using #content, the built-in Typewriter component will be disabled. In the slot, you can also combine it with Typewriter yourself, or customize streaming requests, streaming rendering and other personalized operations.

Properties โ€‹

Property Name
TypeDefaultDescription
contentString''Text content to display inside the bubble
placementString'start'Bubble position, options are 'start' or 'end', representing left and right sides respectively.
avatarString''Image URL for the bubble avatar
loadingBooleanfalseWhether to show loading state. When true, loading state will be displayed inside the bubble.
shapeStringnullBubble shape, options are 'round' (rounded corners) or 'corner' (angular).
variantString'filled'Bubble style variant, options are 'filled' (filled), 'borderless' (no border), 'outlined' (outline), 'shadow' (shadow).
noStyleBooleanfalseWhether to remove styles, when true, removes built-in padding and background color from the bubble
isMarkdownBooleanfalseWhether to process content as Markdown format.
typingBoolean | ObjectfalseWhether to enable typing effect. If object, can set step (characters rendered each time) and suffix (typing cursor suffix content). interval represents typing interval time in ms.
maxWidthString'500px'Maximum width of bubble content.
avatar-sizeString''Set avatar placeholder size
avatar-gapString'12px'Set gap value between avatar and bubble
avatar-shapeString''Avatar shape, options are 'circle' (circular) or 'square' (square).
avatar-iconString''Avatar icon, priority higher than avatar, supports passing icon names like 'user'.
avatar-src-setString''Set avatar image srcset attribute
avatar-altString''Set avatar image alt attribute
avatar-fitString'cover'Set avatar image object-fit attribute, options: 'cover', 'contain', 'fill', 'none', 'scale-down'

Events โ€‹

Event NameParametersTypeDescription
@startref instanceFunctionTriggered when typing effect starts
@finishref instanceFunctionTriggered when typing effect completes
@writingref instanceFunctionTriggered in real-time during typing
@avatarErrorref instanceFunctionTriggered when avatar loading fails

Ref Instance Methods โ€‹

Property NameTypeDescription
interruptFunctionInterrupt typing.
continueFunctionContinue unfinished typing.
restartFunctionRestart typing.
destroyFunctionActively destroy Bubble component.
renderedContentStringGet rendered content of typing component.
isTypingBooleanWhether currently typing.
progressNumberTyping progress, range 0 - 100.

Slots โ€‹

Slot NameParametersTypeDescription
#avatar-SlotCustom avatar display content
#header-SlotCustom bubble top display content
#content-SlotCustom bubble display content
#loading-SlotCustom bubble loading state display content
#footer-SlotCustom bubble bottom display content

Features โ€‹

  1. Layout Direction - Supports left alignment (start) and right alignment (end)
  2. Content Types - Supports plain text, Markdown, custom slot content
  3. Loading State - Built-in loading animation, supports custom loading content
  4. Visual Effects - Provides multiple shapes and variants (rounded/angular corners, filled/outlined/shadow, etc.)
  5. Typing Animation - Supports progressive text output effects
  6. Flexible Slots - Provides avatar, header, content, footer, loading state and other slots