Components Overlays
Popover
Expose short contextual help beside its trigger, with native light dismissal.
A5 sheet
148 × 210 mm. Two A5 sheets fit side by side on an A4 sheet.
Usage
Set Trigger, Title, Description, and Close. On browsers with the Popover API, click outside or press Escape to dismiss. The two buttons use native popovertarget attributes and need no JavaScript.
Register popover with Head and pass its properties to Render. Go setup guide
Go usage
err := mono.UI.Render(w, "popover", mono.Props{
"Close": "Got it",
"Description": "148 × 210 mm. Two A5 sheets fit side by side on an A4 sheet.",
"Title": "A5 sheet",
"Trigger": "Paper size guide",
})Rendered HTML
<div id="demo-popover" data-mono="popover">
<button class="mu-btn" type="button" popovertarget="demo-popover-info">Paper size guide</button>
<section id="demo-popover-info" popover class="mu-panel" aria-labelledby="demo-popover-title">
<div class="mu-stack"><h3 id="demo-popover-title" class="mu-title">A5 sheet</h3>
<p class="mu-muted">148 × 210 mm. Two A5 sheets fit side by side on an A4 sheet.</p>
<button class="mu-btn" type="button" popovertarget="demo-popover-info" popovertargetaction="hide">Got it</button>
</div>
</section>
</div>Go template
<div id="{{.ID}}" data-mono="popover">
<button class="mu-btn" type="button" popovertarget="{{.ID}}-info">{{.Trigger}}</button>
<section id="{{.ID}}-info" popover class="mu-panel" aria-labelledby="{{.ID}}-title">
<div class="mu-stack"><h3 id="{{.ID}}-title" class="mu-title">{{.Title}}</h3>
<p class="mu-muted">{{.Description}}</p>
<button class="mu-btn" type="button" popovertarget="{{.ID}}-info" popovertargetaction="hide">{{.Close}}</button>
</div>
</section>
</div>Component CSS
[data-mono="popover"] [popover] { width: min(18rem, calc(100% - 2rem)); padding: 1rem; border: 1px solid #ccc; border-radius: .55rem; background: white; color: #161616; box-shadow: 0 .55rem 1.75rem #0002; margin: auto; }
[data-mono="popover"] [popover] button { align-self: flex-start; justify-self: start; }
@supports (position-area: bottom) {
[data-mono="popover"] [popover] { inset: auto; position-area: block-end span-inline-end; position-try-fallbacks: flip-block, flip-inline; margin: .4rem 0; }
}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.
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./popover.css">Copy into your project
Run this command from the Mono checkout. Set -out to the component directory in your application.
go run ./cmd/mono-ui add -out ./components popoverExample properties (JSON)
{
"Close": "Got it",
"Description": "148 × 210 mm. Two A5 sheets fit side by side on an A4 sheet.",
"Title": "A5 sheet",
"Trigger": "Paper size guide"
}