logoAnt Design X

Bubble

A bubble component for chat.
Import
import{ Bubble }from"@ant-design/x";

When To Use

Often used when chatting.

Examples

string bubble
longgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
block block block block block block block block block block block block block block block block block block block block block block block block block
fixed width content
string bubble
longgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
block block block block block block block block block block block block block block block block block block block block block block block block block
fixed width content
header
string bubble
header
longgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
header
block block block block block block block block block block block block block block block block block block block block block block block block block
header
fixed width content
header
string bubble
header
longgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
header
block block block block block block block block block block block block block block block block block block block block block block block block block
header
fixed width content
header
string bubble
header
longgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
header
block block block block block block block block block block block block block block block block block block block block block block block block block
header
fixed width content

Only use in debug to check Bubble

codepen icon
External Link Icon
expand codeexpand code
hello world !

Basic usage.

codepen icon
External Link Icon
expand codeexpand code
Good morning, how are you?
What a beautiful day!
Hi, good morning, I'm fine!
Thank you!

Set custom avatar by avatar prop, set the placement of the message by placement prop, which has two preset values: start and end.

codepen icon
External Link Icon
expand codeexpand code
Loading state:

Control the loading state by loading prop.

codepen icon
External Link Icon
expand codeexpand code
A
A💗

Enable typing output by setting the typing prop. If the updated content is a subset of the previous content, it will continue to output, otherwise it will output again.

codepen icon
External Link Icon
expand codeexpand code

Cooperate with markdown-it to achieve customized rendering content.

codepen icon
External Link Icon
expand codeexpand code
variant: filled
variant: outlined
variant: shadow
variant: borderless to customize

How to rest effectively after long hours of work?

What are the secrets to maintaining a positive mindset?

How to stay calm under immense pressure?

Set the style variant of the bubble through the variant property.

codepen icon
External Link Icon
expand codeexpand code
shape: default
This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component.
shape: round
This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component.
shape: corner
This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component. This is a long text message to show the multiline view of the bubble component.

Set the shape of bubble through shape.

codepen icon
External Link Icon
expand codeexpand code
Mock user content.
Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content. Mock AI content.
Mock user content.

Preset Bubble list. Support auto scroll. Use roles to set default properties of Bubble.

codepen icon
External Link Icon
expand codeexpand code
Mock welcome content. Mock welcome content. Mock welcome content. Mock welcome content. Mock welcome content. Mock welcome content. Mock welcome content. Mock welcome content. Mock welcome content. Mock welcome content.
Mock user content.
Custom loading...

Sample for adjusting the bubble effect through semantic and loading customization.

codepen icon
External Link Icon
expand codeexpand code
Normal message
ReactNode message

How to rest effectively after long hours of work?

What are the secrets to maintaining a positive mindset?

How to stay calm under immense pressure?

excel-file
.xlsx
Checking the data
word-file
.docx
23%

Customize the content of the bubble list, which is very useful for personalized customization scenarios.

codepen icon
External Link Icon
expand codeexpand code

API

Common props ref:Common props

Bubble

PropertyDescriptionTypeDefaultVersion
avatarAvatar componentReact.ReactNode-
classNamesSemantic DOM classRecord<SemanticDOM, string>-
contentContent of bubblestring-
footerFooter contentReact.ReactNode-
headerHeader contentReact.ReactNode-
loadingLoading state of Messageboolean-
placementDirection of Messagestart | endstart
shapeShape of bubbleround | corner-
stylesSemantic DOM styleRecord<SemanticDOM, CSSProperties>-
typingShow message with typing motionboolean | { step?: number, interval?: number }false
variantStyle variantfilled | borderless | outlined | shadowfilled
loadingRenderCustomize loading content() => ReactNode-
messageRenderCustomize display content(content?: string) => ReactNode-
onTypingCompleteCallback when typing effect is completed. If typing is not set, it will be triggered immediately when rendering.() => void-

Bubble.List

PropertyDescriptionTypeDefaultVersion
autoScrollWhen the content is updated, scroll to the latest position automatically. If the user scrolls, the automatic scrolling will be paused.booleantrue
itemsBubble items list(BubbleProps & { key?: string | number, role?: string })[]-
rolesSet the default properties of the bubble. The role in items will be automatically matched.Record<string, BubbleProps> | (bubble) => BubbleProps-

Semantic DOM

Ant Design X
Feel free to use Ant Design !
  • avatar
    Wrapper element of the avatar
  • header
    Wrapper element of the header
  • content
    Wrapper element of the content
  • footer
    Wrapper element of the footer

Design Token