Components Data display

Bubble

Give a short conversational reply a distinct incoming or outgoing surface.

Live previewGo + HTML

Print desk: The cover proof is on your desk.

Usage

Set Outgoing to place the bubble at the end of the inline axis. Text holds plain text and preserves line breaks. Include an Author when the speaker is not otherwise identified.

Register bubble with Head and pass its properties to Render. Go setup guide

Go usage
Go usage
err := mono.UI.Render(w, "bubble", mono.Props{
	"Author":   "Print desk",
	"Outgoing": false,
	"Text":     "The cover proof is on your desk.",
})
Rendered HTML
Rendered HTML
<div data-mono="bubble" id="demo-bubble" class="mu-bubble-row" data-outgoing="false">
  <p><span class="mu-sr-only">Print desk: </span>The cover proof is on your desk.</p>
</div>
Go template
Go template
<div data-mono="bubble" id="{{.ID}}" class="mu-bubble-row" data-outgoing="{{if .Outgoing}}true{{else}}false{{end}}">
  <p>{{with .Author}}<span class="mu-sr-only">{{.}}: </span>{{end}}{{.Text}}</p>
</div>
Component CSS
Component CSS
[data-mono="bubble"] { display:flex; }
[data-mono="bubble"] p { margin:0; width:fit-content; max-width:min(85%,36rem); padding:.65rem .95rem; border-radius:.9rem .9rem .9rem .2rem; border:1px solid #d4d4d4; background:#efefef; color:#202020; overflow-wrap:anywhere; white-space:pre-line; }
[data-mono="bubble"][data-outgoing="true"] { justify-content:flex-end; }
[data-mono="bubble"][data-outgoing="true"] p { color:#fff; border-color:#242424; background:#242424; border-radius:.9rem .9rem .2rem .9rem; }
Use the HTML in a static site

Copy the rendered HTML above. Download these assets into the same folder as your page, then add the tags below to its head.

Shared CSS Component CSS

HTML head
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./bubble.css">

Copy into your project

Run this command from the Mono checkout. Set -out to the component directory in your application.

Terminal
go run ./cmd/mono-ui add -out ./components bubble
Example properties (JSON)
example.json
{
  "Author": "Print desk",
  "Outgoing": false,
  "Text": "The cover proof is on your desk."
}