Skip to content

Bubble 对话气泡

用于聊天的气泡组件。

何时使用

常用于聊天的时候。

代码演示

基本

基础用法。

hello world !

支持位置和头像

通过 avatar 设置自定义头像,通过 placement 设置位置,提供了 startend 两个选项。

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

头和尾

通过 headerfooter 属性设置气泡的头部和底部。

Ant Design X
Hello, welcome to use Ant Design X! Just ask if you have any questions.

加载中

通过 loading 属性控制加载状态。

Loading state:

打字效果

通过设置 typing 属性,开启打字效果。更新 content 如果是之前的子集,则会继续输出,否则会重新输出。

Ant Design X love you!
Ant Design X love you!

自定义渲染

配合 markdown-it 实现自定义渲染内容。

Render as markdown content to show ric

变体

通过 variant 属性设置气泡的样式变体。

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?

形状

通过 shape 属性设置气泡的形状。

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.

气泡列表

预设样式的气泡列表,支持自动滚动。使用 roles 设置气泡默认属性。

Use roles as:
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.

语义化自定义

示例通过语义化以及加载定制,来调整气泡效果。

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...

自定义列表内容

自定义气泡列表内容,这对于个性化定制场景非常有用。

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%

使用 GPT-Vis 渲染图表 (no support)

@antv/GPT-Vis 仅支持React。

配合 @antv/GPT-Vis 实现大模型输出的图表渲染,支持模型流式输出。

**GPT-Vis**, Components for GPTs, generative AI, and LLM projects. Not only UI Components. [more...](https://github.com/antvis/GPT-Vis) Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022. You can see a steady increase over the years, with notable *gr

API

Bubble

属性说明类型默认值版本
avatar展示头像VNode-
classNames语义化结构 classRecord<SemanticDOM, string>-
content聊天内容string-
footer底部内容VNode-
header头部内容VNode-
loading聊天内容加载状态boolean-
placement信息位置start | endstart
shape气泡形状round | corner-
styles语义化结构 styleRecord<SemanticDOM, CSSProperties>-
typing设置聊天内容打字动画boolean | { step?: number, interval?: number }false
variant气泡样式变体filled | borderless | outlined | shadowfilled
loadingRender自定义渲染加载态内容() => VNode-
messageRender自定义渲染内容(content?: string) => VNode-
onTypingComplete打字效果完成时的回调,如果没有设置 typing 将在渲染时立刻触发() => void-

Bubble Slots

插槽名说明类型
avatar头像-
header头部面板-
footer底部内容-
loadingloading占位-
message消息内容{ content: string }

Bubble.List

属性说明类型默认值版本
autoScroll当内容更新时,自动滚动到最新位置。如果用户滚动,则会暂停自动滚动。booleantrue
items气泡数据列表(BubbleProps & { key?: string | number, role?: string })[]-
roles设置气泡默认属性,items 中的 role 会进行自动对应Record<string, BubbleProps> | (bubble) => BubbleProps-

Semantic DOM

Ant Design X Vue
Feel free to use Ant Design Vue !
  • avatar
    头像的外层容器
  • header
    头部的容器
  • content
    聊天内容的容器
  • footer
    底部的容器

主题变量(Design Token)