Bubble
A chat bubble. The assistant sits on the left in a soft grey; the person sits on the right, tinted with your accent colour. A typing bubble shows three dots while a reply is coming. Same markup and props in every style: switch the style in the header to see it change.
Basic
The person on the right in the accent tint, the assistant on the left.
Can you suggest a name for my hiking app?
A few ideas: Trailmark, Switchback or Ridgeline.
Trailmark is short, easy to say and the domain is free.
Trailmark it is!
<div class="vin-bubble-group" style="width: 100%; max-width: 460px">
<p class="vin-bubble vin-bubble--user">Can you suggest a name for my hiking app?</p>
<div class="vin-bubble">
<p>A few ideas: <strong>Trailmark</strong>, <strong>Switchback</strong> or <strong>Ridgeline</strong>.</p>
<p>Trailmark is short, easy to say and the domain is free.</p>
</div>
<p class="vin-bubble vin-bubble--user">Trailmark it is!</p>
</div>Can you suggest a name for my hiking app?
A few ideas: Trailmark, Switchback or Ridgeline.
Trailmark is short, easy to say and the domain is free.
Trailmark it is!
import { Bubble, BubbleGroup } from "@/components/vin/bubble";
export function BubbleBasic() {
return (
<BubbleGroup style={{ width: "100%", maxWidth: 460 }}>
<Bubble as="p" from="user">Can you suggest a name for my hiking app?</Bubble>
<Bubble>
<p>A few ideas: <strong>Trailmark</strong>, <strong>Switchback</strong> or <strong>Ridgeline</strong>.</p>
<p>Trailmark is short, easy to say and the domain is free.</p>
</Bubble>
<Bubble as="p" from="user">Trailmark it is!</Bubble>
</BubbleGroup>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Bubble, { BubbleGroup } from "@/components/vin/bubble.vue";
</script>
<template>
<BubbleGroup style="width: 100%; max-width: 460px">
<Bubble as="p" from="user">Can you suggest a name for my hiking app?</Bubble>
<Bubble>
<p>A few ideas: <strong>Trailmark</strong>, <strong>Switchback</strong> or <strong>Ridgeline</strong>.</p>
<p>Trailmark is short, easy to say and the domain is free.</p>
</Bubble>
<Bubble as="p" from="user">Trailmark it is!</Bubble>
</BubbleGroup>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Bubble from "$lib/components/vin/bubble.svelte";
import BubbleGroup from "$lib/components/vin/bubble-group.svelte";
</script>
<BubbleGroup style="width: 100%; max-width: 460px">
<Bubble as="p" from="user">Can you suggest a name for my hiking app?</Bubble>
<Bubble>
<p>A few ideas: <strong>Trailmark</strong>, <strong>Switchback</strong> or <strong>Ridgeline</strong>.</p>
<p>Trailmark is short, easy to say and the domain is free.</p>
</Bubble>
<Bubble as="p" from="user">Trailmark it is!</Bubble>
</BubbleGroup>Solid
A solid accent fill for the person's bubbles, as in messenger apps.
Your order has shipped. It should arrive on Thursday.
Great, thanks!
Can I change the delivery address?
<div class="vin-bubble-group" style="width: 100%; max-width: 460px">
<p class="vin-bubble">Your order has shipped. It should arrive on Thursday.</p>
<p class="vin-bubble vin-bubble--user vin-bubble--solid">Great, thanks!</p>
<p class="vin-bubble vin-bubble--user vin-bubble--solid">Can I change the delivery address?</p>
</div>Your order has shipped. It should arrive on Thursday.
Great, thanks!
Can I change the delivery address?
import { Bubble, BubbleGroup } from "@/components/vin/bubble";
export function BubbleSolid() {
return (
<BubbleGroup style={{ width: "100%", maxWidth: 460 }}>
<Bubble as="p">Your order has shipped. It should arrive on Thursday.</Bubble>
<Bubble as="p" from="user" solid>Great, thanks!</Bubble>
<Bubble as="p" from="user" solid>Can I change the delivery address?</Bubble>
</BubbleGroup>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Bubble, { BubbleGroup } from "@/components/vin/bubble.vue";
</script>
<template>
<BubbleGroup style="width: 100%; max-width: 460px">
<Bubble as="p">Your order has shipped. It should arrive on Thursday.</Bubble>
<Bubble as="p" from="user" solid>Great, thanks!</Bubble>
<Bubble as="p" from="user" solid>Can I change the delivery address?</Bubble>
</BubbleGroup>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Bubble from "$lib/components/vin/bubble.svelte";
import BubbleGroup from "$lib/components/vin/bubble-group.svelte";
</script>
<BubbleGroup style="width: 100%; max-width: 460px">
<Bubble as="p">Your order has shipped. It should arrive on Thursday.</Bubble>
<Bubble as="p" from="user" solid>Great, thanks!</Bubble>
<Bubble as="p" from="user" solid>Can I change the delivery address?</Bubble>
</BubbleGroup>Typing
Three dots while the reply is on its way. They stay still when the reader prefers reduced motion.
Summarise this thread for me.
<div class="vin-bubble-group" style="width: 100%; max-width: 460px">
<p class="vin-bubble vin-bubble--user">Summarise this thread for me.</p>
<div class="vin-bubble vin-bubble--typing" role="status">
<span class="vin-bubble__dot"></span>
<span class="vin-bubble__dot"></span>
<span class="vin-bubble__dot"></span>
<span class="vin-bubble__label">Assistant is typing</span>
</div>
</div>Summarise this thread for me.
import { Bubble, BubbleGroup, TypingBubble } from "@/components/vin/bubble";
export function BubbleTyping() {
return (
<BubbleGroup style={{ width: "100%", maxWidth: 460 }}>
<Bubble as="p" from="user">Summarise this thread for me.</Bubble>
<TypingBubble />
</BubbleGroup>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Bubble, { BubbleGroup, TypingBubble } from "@/components/vin/bubble.vue";
</script>
<template>
<BubbleGroup style="width: 100%; max-width: 460px">
<Bubble as="p" from="user">Summarise this thread for me.</Bubble>
<TypingBubble />
</BubbleGroup>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Bubble from "$lib/components/vin/bubble.svelte";
import BubbleGroup from "$lib/components/vin/bubble-group.svelte";
import TypingBubble from "$lib/components/vin/bubble-typing.svelte";
</script>
<BubbleGroup style="width: 100%; max-width: 460px">
<Bubble as="p" from="user">Summarise this thread for me.</Bubble>
<TypingBubble />
</BubbleGroup>Installation
React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:
npx @vinish/ui add bubbleimport { Bubble, BubbleGroup, TypingBubble } from "@/components/vin/bubble";import Bubble, { BubbleGroup, TypingBubble } from "@/components/vin/bubble.vue";import Bubble from "$lib/components/vin/bubble.svelte";
import BubbleGroup from "$lib/components/vin/bubble-group.svelte";
import TypingBubble from "$lib/components/vin/bubble-typing.svelte";The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.
Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.
API
From spec/bubble.json, which every framework version is tested against.
| Prop | Values | Default | In HTML |
|---|---|---|---|
fromWho is speaking. The person's bubbles sit on the end side. | assistantuser | assistant | vin-bubble--user |
solidWith from="user": a solid accent fill instead of a tint. | boolean | false | vin-bubble--solid |
asUse p for a single line of text. | divp | div | p.vin-bubble or div.vin-bubble |
BubbleGroupA column of bubbles; bubbles from the same speaker sit close together. | children | — | .vin-bubble-group |
TypingBubbleThree dots while a reply is coming. label is what screen readers hear (default "Assistant is typing"). | component | — | .vin-bubble.vin-bubble--typing[role=status] > .vin-bubble__dot ×3 + .vin-bubble__label |
Parts
| React, Vue, Svelte | HTML classes |
|---|---|
<Bubble><BubbleGroup><TypingBubble> | .vin-bubble.vin-bubble--user.vin-bubble--solid.vin-bubble--typing.vin-bubble__dot.vin-bubble__label.vin-bubble-group |
Accessibility
- Bubbles are plain text, so screen readers read them in order. Say who is speaking in nearby text (see Message) when it isn't obvious.
- The typing bubble is a status message with hidden text ("Assistant is typing"), so screen readers announce it without moving focus.
- The dots stop moving when the reader prefers reduced motion or VinUI motion is off.
- Text colours are mixed from the theme so they keep 4.5:1 contrast on the tinted and solid fills.
Customize
Saved in this browser. Style and accent are in the header.