Message Bubble

呈现紧凑会话气泡,并可组合头像、元数据与操作控件。

适用场景

  • 当界面需要以下行为时使用 Message Bubble:呈现紧凑会话气泡,并可组合头像、元数据与操作控件。

安装

选择安装方式,用法示例将同步更新导入路径。

$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/message-bubble.json https://orvui.efu.me/r/message.json https://orvui.efu.me/r/prompt-input.json https://orvui.efu.me/r/streaming-response.json

首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。

示例

Animated Surfaces

surfaces.vue

比较接收消息与发送消息使用的不同气泡表面。

What should we include in the first release?
Start with the smallest workflow that still feels complete.

With Avatars

avatars.vue

将头像选项、消息内容与发送者元数据组合使用。

YouNow
Can you turn these notes into a launch update?
Delivered

Show More

show-more.vue

原地展开较长气泡,保持周围会话控件的位置。

AssistantSummary

The release is ready for a focused rollout. The main conversation flow, keyboard navigation, error recovery, and reduced-motion behavior are all covered.

I would keep advanced workflow controls out of this version. They add configuration without improving the first-run experience, and the usage data from this release will give us a better basis for those decisions.

Before publishing, run the accessibility suite once more and verify the streaming behavior with a long response on a smaller viewport.

组合结构

使用公开部件 MessageBubble, MessageBubbleContent 组合 Message Bubble,并从该组件的公开入口导入。

Message
├── MessageAvatar
└── MessageContent
    └── MessageBubble
        └── MessageBubbleContent

说明: Message 使用内容、附件、来源与操作部件组合会话条目。 Streaming Response 组合持续变化的助手回复,包括文字、附件、引用和操作。

工作方式

呈现紧凑会话气泡,并可组合头像、元数据与操作控件。

状态与事件

需要由表单、路由或父组件管理时,绑定下列状态并接收对应更新。v-model 是属性与 update 事件的简写;值的类型应与 API 一致。

组件状态绑定
组件Vue 绑定更新事件
MessageBubbleCollapsiblev-model:openbooleanupdate:open

可选受控属性未传入时,按组件文档的默认行为工作;不要用固定的 false 或空值代替未传入。异步请求和持久化在应用中处理,再把结果传回组件。

API 参考

Animated Surfaces

MessageBubble

variant?
"ghost" | "outline" | "danger" | "solid" | "soft" | "tint"
"soft"
align?
"start" | "end"
(parent.value === "user" ? "end" : "start")
animateIn?
boolean
false

插槽

default
() => VNodeChild
#default

MessageBubbleContent

as?
string | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"div"

插槽

default
() => VNodeChild
#default

With Avatars

MessageBubble

variant?
"ghost" | "outline" | "danger" | "solid" | "soft" | "tint"
"soft"
align?
"start" | "end"
(parent.value === "user" ? "end" : "start")
animateIn?
boolean
false

插槽

default
() => VNodeChild
#default

MessageBubbleContent

as?
string | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"div"

插槽

default
() => VNodeChild
#default

Show More

MessageBubble

variant?
"ghost" | "outline" | "danger" | "solid" | "soft" | "tint"
"soft"
align?
"start" | "end"
(parent.value === "user" ? "end" : "start")
animateIn?
boolean
false

插槽

default
() => VNodeChild
#default

MessageBubbleCollapsible

open?
boolean
undefined
defaultOpen?
boolean
false
collapsedLines?
2 | 3 | 5 | 4 | 6
4
moreLabel?
boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"Show more"
lessLabel?
boolean | null | string | number | void | VNode<RendererNode, RendererElement, { [key: string]: any; }> | VNodeArrayChildren | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"Show less"
contentClassName?
string
—
triggerClassName?
string
—

事件

update:open
[open: boolean]
@update:open
openChange
[open: boolean]
@openChange

插槽

default
() => VNodeChild
#default

MessageBubbleContent

as?
string | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | FunctionalComponent<any, {}, any, {}> | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions>
"div"

插槽

default
() => VNodeChild
#default

无障碍

为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。

常见问题

如何配置 Message Bubble?
通过 variant、align、animateIn 配置 Message Bubble;API 表列出其类型与默认值。
如何连接到应用状态?
通过default 插槽提供内容,应用副作用由调用方管理。
可以在服务端渲染吗?
可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。

更新于