Docs
Bubble

Bubble

A bubble component for chat.

hello world !

Installation

pnpm dlx shadcn@latest add https://ui.aoian.chat/r/bubble

Usage

import {
  Bubble,
  BubbleContent,
  BubbleWrapper,
} from "@/components/aoian-ui/bubble/bubble"
<Bubble>
  <BubbleWrapper>
    <BubbleContent>hello world !</BubbleContent>
  </BubbleWrapper>
</Bubble>

Examples

Placement and avatar

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

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

Use header and footer properties to set the header and footer of the bubble content.

Aoian UI
Good morning, how are you?

Loading

Control the loading state by loading prop.

Good morning, how are you?
Loading state:

Typing effect

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.

A
A💗

Content render

Cooperate with markdown-it to achieve customized rendering content.

Variant

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

variant: filled
variant: outlined
variant: shadow
variant: borderless to customize

Shape

Set the shape of bubble through 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.
variant: 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.

Bubble List

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

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.

Props

Bubble

PropTypeDefaultDescription
placementstart | endstartDirection of Message
loadingbooleanfalseLoading state of Message
typingboolean | { step?: number, interval?: number }falseShow message with typing motion
avatarPlaceholderbooleanfalseWhether to display the empty avatar
messageRender(content?: string) => ReactNode-Customize display content
onTypingComplete() => void-Callback when typing effect is completed. If typing is not set, it will be triggered immediately when rendering.

BubbleAvatar

PropTypeDefaultDescription
textClassNamestring-Text class name
triggerClassNamestring-Trigger class name
srcstring-Avatar image path
altstringfalseAvatar image alt
loadingbooleanfalseLoading state of Trigger
placeholderboolean-Whether to display the empty avatar, The same as Bubble avatarPlaceholder

BubbleHeader

PropTypeDefaultDescription
classNamestring-Class name

BubbleFooter

PropTypeDefaultDescription
classNamestring-Class name

BubbleContent

PropTypeDefaultDescription
variantfilled | borderless | outlined | shadowfilledStyle variant
shaperound | corner | defaultdefaultShape of bubble

BubbleList

PropTypeDefaultDescription
autoScrollbooleantrueBubble items list
items(BubbleProps & { key?: string | number, role?: string, content: string })[]-Bubble items list
rolesRecord<string, BubbleProps> | (bubble) => BubbleProps-Set the default properties of the bubble. The role in items will be automatically matched.