Components Data display

Reviews & Ratings

Show what readers thought, who wrote each review, and how their ratings add up.

Live previewGo + JavaScript

Form & Function

Reader reviews

Readers on Field Notes, our print journal about how things are made.

Worn wooden letterpress blocks with the letters cut in reverse.
Average rating 4.8 / 5 6 ratings

6 reviews

5.0 out of 5 stars
I bought it for the photographs. The page I keep coming back to is a printer’s pencil sketch in the margin.
Bea LinArt director
4.8 out of 5 stars
Showing the first proof beside the final one settled an argument we’ve had in the type shop for years.
Ellis ReedType designer
4.5 out of 5 stars
I tried the fold on page twelve with a scrap of packing paper. My first one buckled exactly where the maker said it would.
Nell PriceBookbinder
5.0 out of 5 stars
The contact sheet still has the frames they crossed out. I spent longer looking at those than at the finished photograph.
Ada ColePhotographer
4.2 out of 5 stars
The paper study worked with my first-year class. A larger drawing of the last fold would have saved us a second attempt.
Jo MercerWorkshop tutor
5.0 out of 5 stars
Our shop copy falls open at the spread of the little desk lamp. You can tell which pages people read while they wait.
Ravi BellBookseller

Usage

Set Title and pass Reviews in display order. Each review takes a Name and Quote, with optional Role, Avatar URL and numeric Rating from 1 to 5. Decimal scores are supported. Go renders every review and calculates the average from valid scores. Omit Rating to publish a quote on its own. Authors without an Avatar appear with their initials. Set Eyebrow, Intro, Cover and CoverAlt to introduce the collection. Use your own image URLs when copying the component. The sample features fictional readers. At a component width of 680px or more, four or five reviews form two moving columns. Six or more form three columns. Choose Browse reviews to stop the motion and read at your own pace. A scrollable row opens by default on smaller layouts and when the reader prefers reduced motion. Swipe, scroll, or use the previous and next buttons. With the row focused, use Left and Right to move between cards or Home and End to reach either end. Native scrolling also works with JavaScript disabled.

Register reviews-ratings with Head and pass its properties to Render. Go setup guide

To match your site, override --reviews-card for the card background or --reviews-wall-duration for the time each column takes to loop.

Start with two reviews
Start with two reviews
err := mono.UI.Render(w, "reviews-ratings", mono.Props{
    "Title": "Workshop reviews",
    "Reviews": []mono.Props{
        {"Name": "Lou", "Rating": 4.5, "Quote": "I made a second print from the same block."},
        {"Name": "Kit", "Quote": "The folding guide is still pinned above my bench."},
    },
})
Go usage
Go usage
err := mono.UI.Render(w, "reviews-ratings", mono.Props{
	"Cover":    "../components/events/form-function/letterforms.webp",
	"CoverAlt": "Worn wooden letterpress blocks with the letters cut in reverse.",
	"Eyebrow":  "Form & Function",
	"Intro":    "Readers on Field Notes, our print journal about how things are made.",
	"Reviews": []any{
		map[string]any{
			"Avatar": "../components/portraits/bea-lin.webp",
			"Name":   "Bea Lin",
			"Quote":  "I bought it for the photographs. The page I keep coming back to is a printer’s pencil sketch in the margin.",
			"Rating": 5,
			"Role":   "Art director",
		},
		map[string]any{
			"Avatar": "../components/portraits/ellis-reed.webp",
			"Name":   "Ellis Reed",
			"Quote":  "Showing the first proof beside the final one settled an argument we’ve had in the type shop for years.",
			"Rating": 4.8,
			"Role":   "Type designer",
		},
		map[string]any{
			"Name":   "Nell Price",
			"Quote":  "I tried the fold on page twelve with a scrap of packing paper. My first one buckled exactly where the maker said it would.",
			"Rating": 4.5,
			"Role":   "Bookbinder",
		},
		map[string]any{
			"Avatar": "../components/portraits/ada-cole.webp",
			"Name":   "Ada Cole",
			"Quote":  "The contact sheet still has the frames they crossed out. I spent longer looking at those than at the finished photograph.",
			"Rating": 5,
			"Role":   "Photographer",
		},
		map[string]any{
			"Name":   "Jo Mercer",
			"Quote":  "The paper study worked with my first-year class. A larger drawing of the last fold would have saved us a second attempt.",
			"Rating": 4.2,
			"Role":   "Workshop tutor",
		},
		map[string]any{
			"Name":   "Ravi Bell",
			"Quote":  "Our shop copy falls open at the spread of the little desk lamp. You can tell which pages people read while they wait.",
			"Rating": 5,
			"Role":   "Bookseller",
		},
	},
	"Title": "Reader reviews",
})
Rendered HTML
Rendered HTML
<section class="mu-reviews" id="demo-reviews-ratings" data-mono="reviews-ratings" aria-labelledby="demo-reviews-ratings-title">
  <div class="mu-reviews-inner">
    <header class="mu-reviews-head">
      <div class="mu-reviews-intro">
        <p class="mu-reviews-kicker">Form &amp; Function</p>
        <h2 id="demo-reviews-ratings-title">Reader reviews</h2>
        <p class="mu-reviews-deck">Readers on Field Notes, our print journal about how things are made.</p>
      </div>
      
      <div class="mu-reviews-summary">
        <img class="mu-reviews-cover" src="../components/events/form-function/letterforms.webp" alt="Worn wooden letterpress blocks with the letters cut in reverse." decoding="async">
        
        <div class="mu-reviews-verdict">
          <span class="mu-reviews-caption">Average rating</span>
          <strong class="mu-reviews-number">4.8<small> / 5</small></strong>
          <span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:95%"></span>
          <span class="mu-reviews-count">6 ratings</span>
        </div>
        
      </div>
      
    </header>
    
    <div class="mu-reviews-bar">
      <h3>6 reviews</h3>
      <div class="mu-reviews-actions">
        <button type="button" class="mu-reviews-mode" data-review-mode aria-controls="demo-reviews-ratings-rail demo-reviews-ratings-wall" hidden><span data-review-mode-label>Browse reviews</span></button>
        <div class="mu-reviews-nav" data-review-nav hidden>
          <span class="mu-reviews-position" role="status" aria-atomic="true" data-review-position></span>
          <button type="button" aria-label="Previous reviews" aria-controls="demo-reviews-ratings-rail" data-review-prev><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M19 12H5m6 6-6-6 6-6"/></svg></button>
          <button type="button" aria-label="Next reviews" aria-controls="demo-reviews-ratings-rail" data-review-next><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14m-6-6 6 6-6 6"/></svg></button>
        </div>
      </div>
    </div>
    <div class="mu-reviews-stage">
      <div class="mu-reviews-wall" id="demo-reviews-ratings-wall" data-review-wall hidden aria-hidden="true" inert></div>
      <div class="mu-reviews-rail" id="demo-reviews-ratings-rail" role="region" aria-label="Review cards" tabindex="0" data-review-rail>
        
        <figure class="mu-review-card" data-review-card>
          <div class="mu-review-meta">
            
            <span class="mu-review-score"><span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:100%"></span><span>5.0<span class="mu-sr-only"> out of 5 stars</span></span></span>
            
            <span class="mu-review-mark" aria-hidden="true">“</span>
          </div>
          <blockquote>I bought it for the photographs. The page I keep coming back to is a printer’s pencil sketch in the margin.</blockquote>
          <figcaption>
            <span class="mu-review-avatar" aria-hidden="true"><img src="../components/portraits/bea-lin.webp" alt="" loading="lazy" decoding="async" width="40" height="40"></span>
            <span class="mu-review-by"><strong>Bea Lin</strong><span>Art director</span></span>
          </figcaption>
        </figure>
        
        <figure class="mu-review-card" data-review-card>
          <div class="mu-review-meta">
            
            <span class="mu-review-score"><span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:96%"></span><span>4.8<span class="mu-sr-only"> out of 5 stars</span></span></span>
            
            <span class="mu-review-mark" aria-hidden="true">“</span>
          </div>
          <blockquote>Showing the first proof beside the final one settled an argument we’ve had in the type shop for years.</blockquote>
          <figcaption>
            <span class="mu-review-avatar" aria-hidden="true"><img src="../components/portraits/ellis-reed.webp" alt="" loading="lazy" decoding="async" width="40" height="40"></span>
            <span class="mu-review-by"><strong>Ellis Reed</strong><span>Type designer</span></span>
          </figcaption>
        </figure>
        
        <figure class="mu-review-card" data-review-card>
          <div class="mu-review-meta">
            
            <span class="mu-review-score"><span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:90%"></span><span>4.5<span class="mu-sr-only"> out of 5 stars</span></span></span>
            
            <span class="mu-review-mark" aria-hidden="true">“</span>
          </div>
          <blockquote>I tried the fold on page twelve with a scrap of packing paper. My first one buckled exactly where the maker said it would.</blockquote>
          <figcaption>
            <span class="mu-review-avatar" aria-hidden="true">NP</span>
            <span class="mu-review-by"><strong>Nell Price</strong><span>Bookbinder</span></span>
          </figcaption>
        </figure>
        
        <figure class="mu-review-card" data-review-card>
          <div class="mu-review-meta">
            
            <span class="mu-review-score"><span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:100%"></span><span>5.0<span class="mu-sr-only"> out of 5 stars</span></span></span>
            
            <span class="mu-review-mark" aria-hidden="true">“</span>
          </div>
          <blockquote>The contact sheet still has the frames they crossed out. I spent longer looking at those than at the finished photograph.</blockquote>
          <figcaption>
            <span class="mu-review-avatar" aria-hidden="true"><img src="../components/portraits/ada-cole.webp" alt="" loading="lazy" decoding="async" width="40" height="40"></span>
            <span class="mu-review-by"><strong>Ada Cole</strong><span>Photographer</span></span>
          </figcaption>
        </figure>
        
        <figure class="mu-review-card" data-review-card>
          <div class="mu-review-meta">
            
            <span class="mu-review-score"><span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:84%"></span><span>4.2<span class="mu-sr-only"> out of 5 stars</span></span></span>
            
            <span class="mu-review-mark" aria-hidden="true">“</span>
          </div>
          <blockquote>The paper study worked with my first-year class. A larger drawing of the last fold would have saved us a second attempt.</blockquote>
          <figcaption>
            <span class="mu-review-avatar" aria-hidden="true">JM</span>
            <span class="mu-review-by"><strong>Jo Mercer</strong><span>Workshop tutor</span></span>
          </figcaption>
        </figure>
        
        <figure class="mu-review-card" data-review-card>
          <div class="mu-review-meta">
            
            <span class="mu-review-score"><span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:100%"></span><span>5.0<span class="mu-sr-only"> out of 5 stars</span></span></span>
            
            <span class="mu-review-mark" aria-hidden="true">“</span>
          </div>
          <blockquote>Our shop copy falls open at the spread of the little desk lamp. You can tell which pages people read while they wait.</blockquote>
          <figcaption>
            <span class="mu-review-avatar" aria-hidden="true">RB</span>
            <span class="mu-review-by"><strong>Ravi Bell</strong><span>Bookseller</span></span>
          </figcaption>
        </figure>
        
      </div>
    </div>
    
  </div>
</section>
Go template
Go template
{{- $reviews := reviewsRatings .Reviews -}}
<section class="mu-reviews" id="{{.ID}}" data-mono="reviews-ratings" aria-labelledby="{{.ID}}-title">
  <div class="mu-reviews-inner">
    <header class="mu-reviews-head">
      <div class="mu-reviews-intro">
        {{with .Eyebrow}}<p class="mu-reviews-kicker">{{.}}</p>{{end}}
        <h2 id="{{.ID}}-title">{{or .Title "Reviews & ratings"}}</h2>
        {{with .Intro}}<p class="mu-reviews-deck">{{.}}</p>{{end}}
      </div>
      {{if or .Cover $reviews.RatedCount}}
      <div class="mu-reviews-summary">
        {{with .Cover}}<img class="mu-reviews-cover" src="{{.}}" alt="{{or $.CoverAlt ""}}" decoding="async">{{end}}
        {{if $reviews.RatedCount}}
        <div class="mu-reviews-verdict">
          <span class="mu-reviews-caption">Average rating</span>
          <strong class="mu-reviews-number">{{$reviews.Average}}<small> / 5</small></strong>
          <span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:{{$reviews.Fill}}%"></span>
          <span class="mu-reviews-count">{{$reviews.RatedCount}} {{if eq $reviews.RatedCount 1}}rating{{else}}ratings{{end}}</span>
        </div>
        {{end}}
      </div>
      {{end}}
    </header>
    {{if $reviews.Total}}
    <div class="mu-reviews-bar">
      <h3>{{$reviews.Total}} {{if eq $reviews.Total 1}}review{{else}}reviews{{end}}</h3>
      <div class="mu-reviews-actions">
        <button type="button" class="mu-reviews-mode" data-review-mode aria-controls="{{.ID}}-rail {{.ID}}-wall" hidden><span data-review-mode-label>Browse reviews</span></button>
        <div class="mu-reviews-nav" data-review-nav hidden>
          <span class="mu-reviews-position" role="status" aria-atomic="true" data-review-position></span>
          <button type="button" aria-label="Previous reviews" aria-controls="{{.ID}}-rail" data-review-prev><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M19 12H5m6 6-6-6 6-6"/></svg></button>
          <button type="button" aria-label="Next reviews" aria-controls="{{.ID}}-rail" data-review-next><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14m-6-6 6 6-6 6"/></svg></button>
        </div>
      </div>
    </div>
    <div class="mu-reviews-stage">
      <div class="mu-reviews-wall" id="{{.ID}}-wall" data-review-wall hidden aria-hidden="true" inert></div>
      <div class="mu-reviews-rail" id="{{.ID}}-rail" role="region" aria-label="Review cards" tabindex="0" data-review-rail>
        {{range $reviews.Items}}
        <figure class="mu-review-card" data-review-card>
          <div class="mu-review-meta">
            {{if .Score}}
            <span class="mu-review-score"><span class="mu-reviews-stars" aria-hidden="true" style="--review-fill:{{.Fill}}%"></span><span>{{.Score}}<span class="mu-sr-only"> out of 5 stars</span></span></span>
            {{end}}
            <span class="mu-review-mark" aria-hidden="true">“</span>
          </div>
          {{with .Quote}}<blockquote>{{.}}</blockquote>{{end}}
          <figcaption>
            <span class="mu-review-avatar" aria-hidden="true">{{if .Avatar}}<img src="{{.Avatar}}" alt="" loading="lazy" decoding="async" width="40" height="40">{{else}}{{.Initials}}{{end}}</span>
            <span class="mu-review-by"><strong>{{.Name}}</strong>{{with .Role}}<span>{{.}}</span>{{end}}</span>
          </figcaption>
        </figure>
        {{end}}
      </div>
    </div>
    {{else}}
    <p class="mu-reviews-empty">No reviews yet.</p>
    {{end}}
  </div>
</section>
Component CSS
Component CSS
.mu-reviews {
  --reviews-paper: #fff;
  --reviews-ink: #171717;
  --reviews-muted: #525252;
  --reviews-rule: #cecece;
  --reviews-card: #f3f3f3;
  --reviews-gap: .8rem;
  --reviews-wall-duration: 44s;
  container: mono-reviews / inline-size;
  width: 100%;
  min-width: 0;
  color: var(--reviews-ink);
  background: var(--reviews-paper);
}
.mu-reviews-inner { padding: clamp(1rem, 4cqi, 3.75rem); }
.mu-reviews-head {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(1rem, 4cqi, 3.25rem);
  margin-bottom: clamp(1.25rem, 2.8cqi, 2.5rem);
}
.mu-reviews-intro { align-self: center; overflow-wrap: anywhere; }
.mu-reviews-kicker, .mu-reviews-caption, .mu-reviews-position, .mu-reviews-count {
  font: 500 .72rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.mu-reviews-kicker, .mu-reviews-caption { text-transform: uppercase; letter-spacing: .11em; }
.mu-reviews-kicker { display: flex; align-items: center; gap: .7rem; }
.mu-reviews-kicker::before { content: ""; width: 1.75rem; height: 1px; flex: none; background: currentColor; }
.mu-reviews .mu-reviews-intro h2 {
  margin: .65rem 0;
  font-size: clamp(2.5rem, 6.8cqi, 5.8rem);
  line-height: .98;
  letter-spacing: -.067em;
  font-weight: 620;
  color: inherit;
}
.mu-reviews-intro:only-child { grid-column: 1 / -1; }
.mu-reviews .mu-reviews-deck { max-width: 36ch; color: var(--reviews-muted); font-size: clamp(.94rem, 1.35cqi, 1.15rem); line-height: 1.45; }
.mu-reviews-summary {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  min-height: clamp(8.5rem, 16cqi, 14.5rem);
  overflow: hidden;
  background: #171717;
  color: #fff;
  border-radius: .35rem;
}
.mu-reviews-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); }
.mu-reviews-summary:has(.mu-reviews-cover) .mu-reviews-verdict { background: linear-gradient(90deg, #111 2%, #101010eb 25%, #1118 52%, transparent 85%); }
.mu-reviews-verdict {
  z-index: 1;
  display: grid;
  align-content: center;
  justify-items: start;
  height: 100%;
  padding: clamp(.95rem, 2.3cqi, 2.1rem);
}
.mu-reviews-number { font-size: clamp(2.5rem, 4.8cqi, 4.65rem); font-weight: 550; line-height: 1.15; letter-spacing: -.075em; }
.mu-reviews-number small { font-size: .37em; letter-spacing: -.04em; font-weight: 500; }
.mu-reviews-count { margin-top: .4rem; }
.mu-reviews-stars {
  --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m10 1.4 2.6 5.3 5.9.9-4.3 4.1 1 5.9-5.2-2.8-5.2 2.8 1-5.9-4.3-4.1 5.9-.9z'/%3E%3C/svg%3E");
  width: 5em;
  height: 1em;
  display: inline-block;
  flex: none;
  background: linear-gradient(to right, currentColor 0 var(--review-fill), #999 var(--review-fill) 100%);
  mask: var(--star) left center / 1em 1em repeat-x;
}
.mu-reviews-bar, .mu-reviews-actions, .mu-reviews-nav { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.mu-reviews-bar { justify-content: space-between; border-top: 1px solid var(--reviews-ink); padding-block: .65rem; min-height: 3.5rem; }
.mu-reviews-bar h3 { font-size: 1rem; letter-spacing: -.025em; font-weight: 660; }
.mu-reviews-actions { margin-inline-start: auto; justify-content: end; }
.mu-reviews-actions button {
  display: inline-grid;
  place-content: center;
  border: 1px solid var(--reviews-rule);
  border-radius: 99rem;
  background: var(--reviews-paper);
  color: var(--reviews-ink);
  min-height: 2.4rem;
}
.mu-reviews-mode { padding: .4rem .85rem; font-size: .8rem; font-weight: 640; }
.mu-reviews-nav { gap: .3rem; }
.mu-reviews-position { margin-inline-end: .4rem; color: var(--reviews-muted); }
.mu-reviews-nav button { padding: 0; width: 2.4rem; }
.mu-reviews-nav svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mu-reviews-actions button:hover:enabled { color: var(--reviews-paper); background: var(--reviews-ink); border-color: var(--reviews-ink); }
.mu-reviews-stage { position: relative; min-width: 0; }
.mu-reviews-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 2 * var(--reviews-gap)) / 3);
  align-items: stretch;
  gap: var(--reviews-gap);
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: #aaa transparent;
  scroll-snap-type: x mandatory;
}
.mu-reviews-rail:has(> :only-child) { grid-auto-columns: min(100%, 36rem); }
.mu-reviews-rail[data-review-concealed] { position: absolute; inset: 0 auto auto 0; width: 100%; height: 1px; overflow: hidden; clip-path: inset(50%); }
.mu-review-card {
  position: relative;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(1.1rem, 2cqi, 1.85rem);
  border-radius: .85rem;
  background: var(--reviews-card);
  border: 1px solid color-mix(in srgb, var(--reviews-ink) 9%, var(--reviews-card));
  scroll-snap-align: start;
  overflow-wrap: anywhere;
}
.mu-review-meta { display: flex; justify-content: space-between; align-items: center; gap: .35rem; }
.mu-review-score { display: inline-flex; gap: .45rem; align-items: center; font: 650 .8rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.mu-review-score .mu-reviews-stars { font-size: .98rem; }
.mu-review-mark { font: bold 3rem/.4 Georgia, serif; height: .75rem; color: #aaa; margin-inline-start: auto; transform: translateY(.35em); }
.mu-review-card blockquote {
  margin: .95rem 0 1.2rem;
  font: 480 clamp(1.03rem, 1.43cqi, 1.32rem)/1.43 Inter, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -.025em;
}
.mu-review-card figcaption { display: flex; align-items: center; gap: .65rem; margin-top: auto; padding-top: .35rem; }
.mu-review-avatar { display: grid; flex: none; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; overflow: hidden; background: #dedede; color: #282828; font: 550 .75rem/1 ui-monospace, monospace; }
.mu-review-avatar img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); }
.mu-review-by { display: grid; font-size: .84rem; line-height: 1.35; }
.mu-review-by > span { color: var(--reviews-muted); font-size: .78rem; }
.mu-reviews-wall {
  --reviews-wall-height: clamp(18rem, 35cqi, 27rem);
  display: grid;
  grid-template-columns: repeat(var(--review-lanes), minmax(0, 1fr));
  gap: var(--reviews-gap);
  align-items: start;
  height: var(--reviews-wall-height);
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent, #000 6%, #000 91%, transparent);
}
.mu-reviews-wall [data-review-sequence] { display: grid; gap: var(--reviews-gap); padding-bottom: var(--reviews-gap); }
.mu-reviews-wall .mu-review-card { min-height: max(12rem, calc(var(--reviews-wall-height) / 2)); }
.mu-reviews-wall [data-review-lane] { animation: mu-reviews-drift var(--reviews-wall-duration) linear infinite; }
.mu-reviews-wall [data-review-lane]:nth-child(2) { animation-direction: reverse; animation-delay: -11s; }
.mu-reviews-wall [data-review-lane]:nth-child(3) { animation-delay: -4s; }
.mu-reviews-wall[data-review-paused] [data-review-lane] { animation-play-state: paused; }
@media (hover: hover) { .mu-reviews-stage:hover [data-review-lane] { animation-play-state: paused; } }
@media (prefers-reduced-motion: reduce) { .mu-reviews-wall [data-review-lane] { animation: none; } }
@keyframes mu-reviews-drift { to { transform: translateY(-50%); } }
.mu-reviews-empty { border-top: 1px solid var(--reviews-rule); padding-block: 1.25rem; color: var(--reviews-muted); }
@container mono-reviews (max-width: 52rem) {
  .mu-reviews-rail { grid-auto-columns: calc((100% - var(--reviews-gap)) / 2); }
  .mu-reviews-wall { --reviews-wall-height: 22rem; }
}
@container mono-reviews (max-width: 36rem) {
  .mu-reviews-head { grid-template-columns: 1fr; }
  .mu-reviews-summary { min-height: 8rem; }
  .mu-reviews-verdict { grid-template-columns: auto 1fr; gap: 0 .7rem; align-items: baseline; }
  .mu-reviews-caption { grid-column: 1 / -1; }
  .mu-reviews-count { grid-column: 1 / -1; margin: 0; }
  .mu-reviews-rail { grid-auto-columns: 89%; }
}
@media (forced-colors: active) {
  .mu-reviews-stars { display: none; }
  .mu-review-card, .mu-reviews-summary { border: 1px solid CanvasText; }
  .mu-reviews-verdict { color: CanvasText; background: Canvas !important; }
}
JavaScript module
JavaScript module
export function mount(root) {
  const rail = root.querySelector('[data-review-rail]');
  const cards = rail ? Array.from(rail.children).filter(card => card.matches('[data-review-card]')) : [];
  const nav = root.querySelector('[data-review-nav]');
  if (!nav || cards.length < 2) return;

  const prev = nav.querySelector('[data-review-prev]');
  const next = nav.querySelector('[data-review-next]');
  const position = nav.querySelector('[data-review-position]');
  const wall = root.querySelector('[data-review-wall]');
  const mode = root.querySelector('[data-review-mode]');
  const modeLabel = mode?.querySelector('[data-review-mode-label]');
  const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
  let preferWall = true;
  let direction = 1;
  let width = 0;
  let limit = 0;
  let bounds = [];
  let stops = [];
  let destination = null;
  let frame = 0;

  function buildWall() {
    const lanes = cards.length >= 6 ? 3 : 2;
    const fragment = document.createDocumentFragment();
    for (let laneIndex = 0; laneIndex < lanes; laneIndex++) {
      const lane = document.createElement('div');
      const sequence = document.createElement('div');
      lane.setAttribute('data-review-lane', '');
      sequence.setAttribute('data-review-sequence', '');
      for (let i = laneIndex; i < cards.length; i += lanes) {
        sequence.append(cards[i].cloneNode(true));
      }
      lane.append(sequence, sequence.cloneNode(true));
      fragment.append(lane);
    }
    wall.style.setProperty('--review-lanes', lanes);
    wall.append(fragment);
  }

  function offset() {
    return Math.max(0, Math.min(limit, direction * rail.scrollLeft));
  }

  function update() {
    frame = 0;
    if (nav.hidden) return;
    const start = offset();
    prev.disabled = start <= 1;
    next.disabled = start >= limit - 1;
    if (destination !== null && Math.abs(start - destination) <= 1) destination = null;

    // Count a card once at least half of it (or half the viewport) can be read.
    const visible = [];
    bounds.forEach(({start: left, end: right}, index) => {
      const overlap = Math.min(start + width, right) - Math.max(start, left);
      if (overlap + 1 >= Math.min(width, right - left) / 2) visible.push(index + 1);
    });
    if (!visible.length) return;
    const first = visible[0];
    const last = visible[visible.length - 1];
    const label = (first === last ? 'Review ' + first : 'Reviews ' + first + '–' + last) + ' of ' + cards.length;
    if (position.textContent !== label) position.textContent = label;
  }

  function measure() {
    const canPlay = wall && mode && cards.length >= 4 && !reducedMotion.matches && root.clientWidth >= 680;
    const playing = Boolean(canPlay && preferWall);
    if (playing && !wall.childElementCount) buildWall();
    if (wall) wall.hidden = !playing;
    if (mode) {
      mode.hidden = !canPlay;
      if (modeLabel) modeLabel.textContent = playing ? 'Browse reviews' : 'Play review wall';
      const target = playing ? rail : wall;
      if (target?.id) mode.setAttribute('aria-controls', target.id);
    }
    rail.toggleAttribute('data-review-concealed', playing);
    rail.tabIndex = playing ? -1 : 0;
    if (playing) {
      nav.hidden = true;
      return;
    }
    direction = getComputedStyle(rail).direction === 'rtl' ? -1 : 1;
    width = rail.clientWidth;
    limit = Math.max(0, rail.scrollWidth - width);
    nav.hidden = !width || limit <= 1;
    if (nav.hidden) return;
    const start = offset();
    const edge = rail.getBoundingClientRect().left + rail.clientLeft + (direction === -1 ? width : 0);
    bounds = cards.map(card => {
      const rect = card.getBoundingClientRect();
      const left = start + direction * ((direction === -1 ? rect.right : rect.left) - edge);
      return {start: left, end: left + rect.width};
    });
    stops = bounds.map(card => card.start - bounds[0].start).filter(stop => stop < limit - 1);
    stops.push(limit);
    destination = null;
    update();
  }

  function move(action) {
    const from = destination ?? offset();
    switch (action) {
      case 'first': destination = 0; break;
      case 'last': destination = limit; break;
      case 'previous': destination = stops.findLast(stop => stop < from - 1) ?? 0; break;
      case 'next': destination = stops.find(stop => stop > from + 1) ?? limit; break;
    }
    rail.scrollTo({left: direction * destination, behavior: reducedMotion.matches ? 'instant' : 'smooth'});
  }

  prev.addEventListener('click', () => move('previous'));
  next.addEventListener('click', () => move('next'));
  rail.addEventListener('keydown', event => {
    if (event.target !== rail || nav.hidden || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
    const actions = {Home: 'first', End: 'last', ArrowLeft: direction === 1 ? 'previous' : 'next', ArrowRight: direction === 1 ? 'next' : 'previous'};
    if (!Object.hasOwn(actions, event.key)) return;
    event.preventDefault();
    move(actions[event.key]);
  });
  rail.addEventListener('scroll', () => {
    if (!frame) frame = requestAnimationFrame(update);
  }, {passive: true});
  const clearDestination = () => { destination = null; };
  rail.addEventListener('pointerdown', clearDestination, {passive: true});
  rail.addEventListener('wheel', clearDestination, {passive: true});
  mode?.addEventListener('click', () => {
    preferWall = !preferWall;
    measure();
  });
  reducedMotion.addEventListener('change', measure);
  if (wall && cards.length >= 4) {
    let onScreen = true;
    const updatePlayback = () => wall.toggleAttribute('data-review-paused', !onScreen || document.hidden);
    document.addEventListener('visibilitychange', updatePlayback);
    if ('IntersectionObserver' in window) {
      const visibility = new IntersectionObserver(([entry]) => {
        onScreen = entry.isIntersecting;
        updatePlayback();
      });
      visibility.observe(root);
    }
    updatePlayback();
  }
  if ('ResizeObserver' in window) {
    const observer = new ResizeObserver(measure);
    observer.observe(root);
    observer.observe(rail);
    cards.forEach(card => observer.observe(card));
  } else {
    window.addEventListener('resize', measure);
  }
  measure();
}
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 Ready-to-use module

HTML head
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./reviews-ratings.css">
<script type="module" src="./reviews-ratings.js"></script>

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 reviews-ratings
Example properties (JSON)
example.json
{
  "Cover": "../components/events/form-function/letterforms.webp",
  "CoverAlt": "Worn wooden letterpress blocks with the letters cut in reverse.",
  "Eyebrow": "Form \u0026 Function",
  "Intro": "Readers on Field Notes, our print journal about how things are made.",
  "Reviews": [
    {
      "Avatar": "../components/portraits/bea-lin.webp",
      "Name": "Bea Lin",
      "Quote": "I bought it for the photographs. The page I keep coming back to is a printer’s pencil sketch in the margin.",
      "Rating": 5,
      "Role": "Art director"
    },
    {
      "Avatar": "../components/portraits/ellis-reed.webp",
      "Name": "Ellis Reed",
      "Quote": "Showing the first proof beside the final one settled an argument we’ve had in the type shop for years.",
      "Rating": 4.8,
      "Role": "Type designer"
    },
    {
      "Name": "Nell Price",
      "Quote": "I tried the fold on page twelve with a scrap of packing paper. My first one buckled exactly where the maker said it would.",
      "Rating": 4.5,
      "Role": "Bookbinder"
    },
    {
      "Avatar": "../components/portraits/ada-cole.webp",
      "Name": "Ada Cole",
      "Quote": "The contact sheet still has the frames they crossed out. I spent longer looking at those than at the finished photograph.",
      "Rating": 5,
      "Role": "Photographer"
    },
    {
      "Name": "Jo Mercer",
      "Quote": "The paper study worked with my first-year class. A larger drawing of the last fold would have saved us a second attempt.",
      "Rating": 4.2,
      "Role": "Workshop tutor"
    },
    {
      "Name": "Ravi Bell",
      "Quote": "Our shop copy falls open at the spread of the little desk lamp. You can tell which pages people read while they wait.",
      "Rating": 5,
      "Role": "Bookseller"
    }
  ],
  "Title": "Reader reviews"
}