Bubble
Importimport { Bubble } from "@ant-design/x"; |
Sourcecomponents/bubble |
Importimport { Bubble } from "@ant-design/x"; |
Sourcecomponents/bubble |
Often used when chatting.
Common Props Reference: Common Props
| Attributes | Description | Type | Default | Version |
|---|---|---|---|---|
| prefixCls | Custom class prefixes | string | - | - |
| rootStyle | Root Node Style | React.CSSProperties | - | - |
| styles | Semantic structure style | Record<SemanticDOM, CSSProperties> | - | |
| rootClassName | Root node class name | string | - | - |
| classNames | Semantic structure class | Record<SemanticDOM, string> | - | |
| placement | Bubble Location | start | end | start | - |
| loading | Load Status | boolean | - | - |
| loadingRender | Custom loading content rendering | () => React.ReactNode | - | - |
| content | Bubble Contents | ContentType | - | - |
| contentRender | Custom content rendering | (content: ContentType) => React.ReactNode | - | - |
| typing | Typing Animation Effects | boolean | BubbleAnimationOption | false | - |
| streaming | Whether it is streaming | boolean | false | - |
| variant | Bubble style variants | filled | outlined | shadow | borderless | filled | - |
| shape | Bubble Shape | default | round | corner | default | - |
| footerPlacement | Bottom Slot Position | outer-start | outer-end | inner-start | inner-end | outer-start | - |
| components | Expand Slot Configuration | { header?: BubbleSlot; footer?: BubbleSlot; avatar?: BubbleSlot; extra?: BubbleSlot; } | - | - |
| onTyping | Animation Execution Callback | (rendererContent: string, currentContent: string) => void | - | - |
| onTypingComplete | Animation end callback | (content: string) => void | - | - |
streaming can be passed to tell Bubble if the current content is a streaming input. When in streaming mode, with or without Bubble input animation, the Bubble will not trigger the onTypingComplete callback until streaming becomes false, even if the current content has fully outputted. This avoids the issue of multiple triggers of onTypingComplete callbacks due to unstable streaming, ensuring that only onTypingComplete is triggered once during a streaming process.
In this example, you can try to force the streaming flag to be turned off while
onTypingComplete will be triggered multiple times when performing a load slowly because the streaming speed cannot keep up with the animation speed.onTypingComplete will be triggered every time you stream the input.| Attributes | Description | Type | Default | Version |
|---|---|---|---|---|
| prefixCls | Custom class prefixes | string | - | - |
| rootClassName | Root node class name | string | - | - |
| rootStyle | Root Node Style | React.CSSProperties | - | - |
| items | Bubble data list, key, role required | (BubbleProps & { key: string | number, role: string }) [] | - | - |
| autoScroll | Whether to auto-scroll | boolean | true | - |
| role | Role default configuration | Partial<Record<ai | system | user, RoleType>> & Record<string, RoleType> | - | - |
Default type
type ContentType = React.ReactNode | AnyObject | string | number;
Custom type usage
type CustomContentType {...}<Bubble<CustomContentType> {... props} />
type BubbleSlot<ContentType> = React.ReactNode | ((content: ContentType) => React.ReactNode);
interface BubbleAnimationOption {/*** @description Animation effect type, typewriter, fade*/effect: 'typing' | 'fade-in';/*** @description Content step units, array format as random intervals*/step?: number | [number, number];/*** @description Animation trigger interval*/interval?: number;/*** @description Whether to restart an animation with the common prefix of the text*/keepPrefix?: boolean;/*** @description Stepping UI under typewriter effect*/suffix?: React.ReactNode;}
type RoleType = Pick<BubbleProps,| 'typing'| 'variant'| 'shape'| 'placement'| 'rootClassName'| 'classNames'| 'className'| 'rootStyle'| 'styles'| 'style'| 'loading'| 'loadingRender'| 'contentRender'| 'footerPlacement'| 'components'> & { key: string | number; role: string };