Bubble 对话气泡

用于聊天的气泡组件。
使用

何时使用#

常用于聊天的时候。

代码演示#

hello world!

基础用法。

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

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

      加载中
    
Loading State:

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

      加载中
    
Ant Design X love you!
Ant Design X love you!

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

      加载中
    

Render as markdown content to show rich text!

Link: Ant Design X

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

      加载中
    
variant: filled
variant: outlined
variant: shadow
prompt

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

      加载中
    
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.

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

      加载中
    
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.

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

      加载中
    
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...

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

      加载中
    

API#

nx-bubble#

PropertyDescriptionTypeDefault
[nxContent]气泡内容string''
[nxMessageRender]自定义消息渲染模板TemplateRef<{ content: string }> | nullnull
[nxAvatar]头像组件或属性NxBubbleAvatar-
[nxHeader]气泡头部内容string | TemplateRef<void> | nullnull
[nxFooter]气泡底部内容string | TemplateRef<void> | nullnull
[nxLoading]加载状态boolean-
[nxLoadingRender]自定义加载状态渲染模板TemplateRef<void> | nullnull
[nxPlacement]气泡位置NxBubblePlacement'start'
[nxShape]气泡形状NxBubbleShape'default'
[nxTyping]打字机效果配置boolean | NxTypingOptionDEFAULT_TYPING_OPTION
[nxVariant]气泡变体NxBubbleVariant'filled'
(nxContentUpdate)内容更新时触发的回调EventEmitter<void>-
(nxTypingComplete)打字机效果完成时触发的回调EventEmitter<void>-

nx-bubble-list#

PropertyDescriptionTypeDefault
[nxAutoScroll]是否在内容更新时自动滚动到最新位置booleantrue
[nxItems]气泡列表项NxBubbleListItem[]必填
[nxRoles]设置气泡的默认属性,role 会自动匹配NxBubbleRoles-
interface NxBubbleListItem {
  key?: string;
  role?: string;
  content?: string;
  loading?: boolean;
  placement?: NxBubblePlacement;
  shape?: NxBubbleShape;
  variant?: NxBubbleVariant;
  typing?: boolean | NxTypingOption;
  avatar?: NxBubbleAvatar;
  headerRender?: TemplateRef<{ content: string; info: { key?: string } }> | null;
  footerRender?: TemplateRef<{ content: string; info: { key?: string } }> | null;
  messageRender?: TemplateRef<{ content: string }> | null;
  loadingRender?: TemplateRef<void> | null;
}