Skip to content

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!

bubble-basic.html
<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>

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?

bubble-solid.html
<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>

Typing

Three dots while the reply is on its way. They stay still when the reader prefers reduced motion.

Summarise this thread for me.

Assistant is typing
bubble-typing.html
<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>

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:

Terminal
npx @vinish/ui add bubble
React
import { Bubble, BubbleGroup, TypingBubble } from "@/components/vin/bubble";
Vue
import Bubble, { BubbleGroup, TypingBubble } from "@/components/vin/bubble.vue";
Svelte
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.

PropValuesDefaultIn HTML
from
Who is speaking. The person's bubbles sit on the end side.
assistantuserassistantvin-bubble--user
solid
With from="user": a solid accent fill instead of a tint.
booleanfalsevin-bubble--solid
as
Use p for a single line of text.
divpdivp.vin-bubble or div.vin-bubble
BubbleGroup
A column of bubbles; bubbles from the same speaker sit close together.
children—.vin-bubble-group
TypingBubble
Three 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, SvelteHTML 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.