Skip to content

AiBubble

AiBubble is the core component for AI conversation interaction.

Basic Usage

Display visual differences between user and assistant, along with loading animations.

Artificial Intelligence (AI) is technology that can perform tasks that typically require human intelligence.

Can it write code by itself?

Basic Usage

Advanced Features & Variants

AiBubble features a built-in Markdown engine and highlight.js parsing. It offers various variants (variant), shapes (shape), and specialized metadata support.

10:23 AM

This is a Markdown rendering example. Let’s see some code:

const greeting = 'Hello World';
console.log(greeting);

Great! Can I change the style?

Sure, this is outlined mode.

It looks really premium.

If you don’t like outlines, you can use borderless mode.

Advanced Combo

Typewriter Effect & 60fps Streaming

More than just a loading state, it allows text to flow out with a flickering cursor, mimicking the AI writing experience.

  • Streaming Performance: Under the hood, we introduced a requestAnimationFrame debouncing queue. When receiving high-frequency text payloads in typing mode, it stabilizes the intense Markdown parsing and keeps your browser refreshing at a seamless 60 frames per second without blocking the main thread!
Typewriter Effect

Citations & Reference Tooltip

AI responses often need verification to avoid hallucinations. Besides appending a raw list at the bottom, we injected a smart Citation syntax interceptor natively. If the citations array is present and the model outputs Markdown tags like [1] or [2]: the bubble automatically transforms them into interactive, softly-glowing citation badges. 💡 Try it: Hover your mouse over [1], [2], or [3] in the text below to trigger the elegant floating citation popover.

According to the latest YH-UI guide 1, we recommend using Composition API 2. Moreover, Vite’s build optimizations 3 can significantly improve UX.

Citations

Multimodal Rendering

The component supports direct display of various media formats, including image grids, audio players with waveform animations, and file/download cards.

Prototype 1
Prototype 2

Here are the audio assets and reference documents I generated for you.

0:02
Requirements.pdf
1.2 MB
Multimodal

Theme Overrides

Besides global CSS variables, you can use the theme-overrides property for granular instance-level styling.

I’ve adjusted my appearance based on your brand colors.

Instance Level Overrides

API

Props

PropertyDescriptionTypeDefault
contentMessage contentstring''
markdownEnable Markdown & highlight.jsbooleantrue
roleSender role'user' | 'assistant' | 'system''assistant'
placementBubble side'start' | 'end'Inferred from role
shapeCorner shape'corner' | 'round''corner'
variantVisual style'filled' | 'outlined' | 'shadow' | 'borderless''filled'
timeTimestamp labelstring
avatarCustom avatar URLstring
loadingWhether is loadingbooleanfalse
typingShow typewriter cursor animationbooleanfalse
citationsCitation sources listAiCitation[][]
multimodalMultimodal content listAiMultimodal[][]
themeOverridesTheme variable overridesComponentThemeVars

AiCitation

PropertyDescriptionType
idIndex identifierstring | number
titleTitle of sourcestring
urlWeb linkstring
sourceSource site namestring
iconSource iconstring

AiMultimodal

PropertyDescriptionType
typeMedia type'image' | 'audio' | 'file' | 'video'
titleTitle/Filenamestring
urlResource URLstring
sizeResource sizestring
extraExtra args (e.g. duration)Record<string, unknown>

Slots

NameDescriptionProps
defaultCustom content
avatarCustom avatar
headerCustom header
footerCustom footer

Theme Variables

Variable NameDescriptionDefault Value
--yh-ai-bubble-user-bgUser bubble backgroundvar(--yh-color-primary)
--yh-ai-bubble-user-colorUser bubble text colorvar(--yh-color-white)
--yh-ai-bubble-assistant-bgAI bubble backgroundvar(--yh-fill-color-light)
--yh-ai-bubble-assistant-colorAI bubble text colorvar(--yh-text-color-primary)
--yh-ai-bubble-border-radiusBubble border radius12px

Released under the MIT License.