Components Feedback

Skeleton

Reserve space while an asynchronous section is loading.

Live previewGo + HTML
Loading article preview

Usage

Pass one Label describing the pending content. Replace the skeleton with the completed content when it arrives. The pulse stops on devices that request reduced motion.

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

Go usage
Go usage
err := mono.UI.Render(w, "skeleton", mono.Props{
	"Label": "Loading article preview",
})
Rendered HTML
Rendered HTML
<div data-mono="skeleton" id="demo-skeleton" role="status" class="mu-stack">
  <span class="mu-sr-only">Loading article preview</span>
  <span aria-hidden="true" class="mu-skel-line"></span><span aria-hidden="true" class="mu-skel-line"></span><span aria-hidden="true" class="mu-skel-line"></span>
</div>
Go template
Go template
<div data-mono="skeleton" id="{{.ID}}" role="status" class="mu-stack">
  <span class="mu-sr-only">{{.Label}}</span>
  <span aria-hidden="true" class="mu-skel-line"></span><span aria-hidden="true" class="mu-skel-line"></span><span aria-hidden="true" class="mu-skel-line"></span>
</div>
Component CSS
Component CSS
[data-mono="skeleton"] { width:100%; max-width:23rem; }
[data-mono="skeleton"] .mu-skel-line { display:block; height:.8rem; width:100%; border-radius:.2rem; background:#ccc; }
[data-mono="skeleton"] .mu-skel-line:first-of-type + .mu-skel-line { height:1.25rem; width:58%; }
[data-mono="skeleton"] .mu-skel-line:last-child { width:78%; }
@media (prefers-reduced-motion:no-preference) {
  [data-mono="skeleton"] .mu-skel-line { animation:mu-skeleton-fade 1.7s ease-in-out infinite alternate; }
  @keyframes mu-skeleton-fade { to { opacity:.5; } }
}
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="./skeleton.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 skeleton
Example properties (JSON)
example.json
{
  "Label": "Loading article preview"
}