Components Data display

Testimonial expand

Hover or tap an author to expand their quote.

Live previewGo + JavaScript
We pinned the first proof above the press. By Friday, half the studio had asked for a copy.
The lowercase g took three rounds. Seeing it on the finished cover made every one of them worth it.
They left just enough white space for the quietest line in the essay to land.
There’s a little grain at the edge of the black. I’m glad we kept it. You can tell a person pulled that print.
I sent a contact sheet with one frame circled. They built a whole spread around the light in that frame.
My favorite detail is the spine. You can find this book on a crowded shelf from across the room.

Usage

Pass a Label and an Items list. Give each item a Name and Quote, then add an optional Role, Initials, ImageURL, or whole-number Rating from 1 to 5. The sample uses fictional contributors. Replace the demo photo paths with your own, or omit ImageURL to show initials. Hover over an author with a mouse, tap a name, or tab into the group and use the arrow keys. Selection stays in place when the pointer leaves. On narrow layouts and for groups of more than six, authors appear in a vertical list.

Register testimonial-expand with Head and pass its properties to Render. Go setup guide

Go usage
Go usage
err := mono.UI.Render(w, "testimonial-expand", mono.Props{
	"Items": []any{
		map[string]any{
			"ImageURL": "../components/portraits/bea-lin.webp",
			"Initials": "BL",
			"Name":     "Bea Lin",
			"Quote":    "We pinned the first proof above the press. By Friday, half the studio had asked for a copy.",
			"Rating":   5,
			"Role":     "Art director",
		},
		map[string]any{
			"ImageURL": "../components/portraits/ellis-reed.webp",
			"Initials": "ER",
			"Name":     "Ellis Reed",
			"Quote":    "The lowercase g took three rounds. Seeing it on the finished cover made every one of them worth it.",
			"Rating":   5,
			"Role":     "Type designer",
		},
		map[string]any{
			"ImageURL": "../components/portraits/mira-shah.webp",
			"Initials": "MS",
			"Name":     "Mira Shah",
			"Quote":    "They left just enough white space for the quietest line in the essay to land.",
			"Rating":   4,
			"Role":     "Editor",
		},
		map[string]any{
			"ImageURL": "../components/portraits/felix-hart.webp",
			"Initials": "FH",
			"Name":     "Felix Hart",
			"Quote":    "There’s a little grain at the edge of the black. I’m glad we kept it. You can tell a person pulled that print.",
			"Rating":   5,
			"Role":     "Printmaker",
		},
		map[string]any{
			"ImageURL": "../components/portraits/ada-cole.webp",
			"Initials": "AC",
			"Name":     "Ada Cole",
			"Quote":    "I sent a contact sheet with one frame circled. They built a whole spread around the light in that frame.",
			"Rating":   5,
			"Role":     "Photographer",
		},
		map[string]any{
			"ImageURL": "../components/portraits/theo-park.webp",
			"Initials": "TP",
			"Name":     "Theo Park",
			"Quote":    "My favorite detail is the spine. You can find this book on a crowded shelf from across the room.",
			"Rating":   5,
			"Role":     "Book designer",
		},
	},
	"Label": "Studio notes",
})
Rendered HTML
Rendered HTML
<section id="demo-testimonial-expand" data-mono="testimonial-expand" aria-label="Studio notes">
  
  <div class="mu-voice-deck" role="radiogroup" aria-label="Studio notes" style="--voice-count: 6">
    
    <div class="mu-voice-card">
      <input type="radio" class="mu-sr-only mu-voice-radio" id="demo-testimonial-expand-voice-0" name="demo-testimonial-expand-reader" value="Bea Lin" aria-label="Bea Lin" aria-describedby="demo-testimonial-expand-quote-0" checked>
      <div class="mu-voice-story">
        <div class="mu-voice-meta" aria-hidden="true">
          <svg width="32" height="26" viewBox="0 0 32 26" fill="currentColor" focusable="false"><path d="M1 25v-9C1 8 5 3 13 1v4c-4 2-6 5-6 9h6v11H1Zm17 0v-9c0-8 4-13 12-15v4c-4 2-6 5-6 9h6v11H18Z"/></svg>
          <span class="mu-voice-count"> / 06</span>
        </div>
        <blockquote id="demo-testimonial-expand-quote-0">We pinned the first proof above the press. By Friday, half the studio had asked for a copy.</blockquote>
      </div>
      <label for="demo-testimonial-expand-voice-0" class="mu-voice-author">
        <span class="mu-voice-photo" aria-hidden="true">
  <span>BL</span><img src="../components/portraits/bea-lin.webp" width="48" height="48" alt="" loading="lazy" decoding="async">
</span>
        <span class="mu-voice-credit"><strong>Bea Lin</strong><span class="mu-voice-role">Art director</span></span>
        <span class="mu-voice-stars" data-rating="5" role="img" aria-label="5 out of 5 stars"></span>
      </label>
    </div>
    
    <div class="mu-voice-card">
      <input type="radio" class="mu-sr-only mu-voice-radio" id="demo-testimonial-expand-voice-1" name="demo-testimonial-expand-reader" value="Ellis Reed" aria-label="Ellis Reed" aria-describedby="demo-testimonial-expand-quote-1" >
      <div class="mu-voice-story">
        <div class="mu-voice-meta" aria-hidden="true">
          <svg width="32" height="26" viewBox="0 0 32 26" fill="currentColor" focusable="false"><path d="M1 25v-9C1 8 5 3 13 1v4c-4 2-6 5-6 9h6v11H1Zm17 0v-9c0-8 4-13 12-15v4c-4 2-6 5-6 9h6v11H18Z"/></svg>
          <span class="mu-voice-count"> / 06</span>
        </div>
        <blockquote id="demo-testimonial-expand-quote-1">The lowercase g took three rounds. Seeing it on the finished cover made every one of them worth it.</blockquote>
      </div>
      <label for="demo-testimonial-expand-voice-1" class="mu-voice-author">
        <span class="mu-voice-photo" aria-hidden="true">
  <span>ER</span><img src="../components/portraits/ellis-reed.webp" width="48" height="48" alt="" loading="lazy" decoding="async">
</span>
        <span class="mu-voice-credit"><strong>Ellis Reed</strong><span class="mu-voice-role">Type designer</span></span>
        <span class="mu-voice-stars" data-rating="5" role="img" aria-label="5 out of 5 stars"></span>
      </label>
    </div>
    
    <div class="mu-voice-card">
      <input type="radio" class="mu-sr-only mu-voice-radio" id="demo-testimonial-expand-voice-2" name="demo-testimonial-expand-reader" value="Mira Shah" aria-label="Mira Shah" aria-describedby="demo-testimonial-expand-quote-2" >
      <div class="mu-voice-story">
        <div class="mu-voice-meta" aria-hidden="true">
          <svg width="32" height="26" viewBox="0 0 32 26" fill="currentColor" focusable="false"><path d="M1 25v-9C1 8 5 3 13 1v4c-4 2-6 5-6 9h6v11H1Zm17 0v-9c0-8 4-13 12-15v4c-4 2-6 5-6 9h6v11H18Z"/></svg>
          <span class="mu-voice-count"> / 06</span>
        </div>
        <blockquote id="demo-testimonial-expand-quote-2">They left just enough white space for the quietest line in the essay to land.</blockquote>
      </div>
      <label for="demo-testimonial-expand-voice-2" class="mu-voice-author">
        <span class="mu-voice-photo" aria-hidden="true">
  <span>MS</span><img src="../components/portraits/mira-shah.webp" width="48" height="48" alt="" loading="lazy" decoding="async">
</span>
        <span class="mu-voice-credit"><strong>Mira Shah</strong><span class="mu-voice-role">Editor</span></span>
        <span class="mu-voice-stars" data-rating="4" role="img" aria-label="4 out of 5 stars"></span>
      </label>
    </div>
    
    <div class="mu-voice-card">
      <input type="radio" class="mu-sr-only mu-voice-radio" id="demo-testimonial-expand-voice-3" name="demo-testimonial-expand-reader" value="Felix Hart" aria-label="Felix Hart" aria-describedby="demo-testimonial-expand-quote-3" >
      <div class="mu-voice-story">
        <div class="mu-voice-meta" aria-hidden="true">
          <svg width="32" height="26" viewBox="0 0 32 26" fill="currentColor" focusable="false"><path d="M1 25v-9C1 8 5 3 13 1v4c-4 2-6 5-6 9h6v11H1Zm17 0v-9c0-8 4-13 12-15v4c-4 2-6 5-6 9h6v11H18Z"/></svg>
          <span class="mu-voice-count"> / 06</span>
        </div>
        <blockquote id="demo-testimonial-expand-quote-3">There’s a little grain at the edge of the black. I’m glad we kept it. You can tell a person pulled that print.</blockquote>
      </div>
      <label for="demo-testimonial-expand-voice-3" class="mu-voice-author">
        <span class="mu-voice-photo" aria-hidden="true">
  <span>FH</span><img src="../components/portraits/felix-hart.webp" width="48" height="48" alt="" loading="lazy" decoding="async">
</span>
        <span class="mu-voice-credit"><strong>Felix Hart</strong><span class="mu-voice-role">Printmaker</span></span>
        <span class="mu-voice-stars" data-rating="5" role="img" aria-label="5 out of 5 stars"></span>
      </label>
    </div>
    
    <div class="mu-voice-card">
      <input type="radio" class="mu-sr-only mu-voice-radio" id="demo-testimonial-expand-voice-4" name="demo-testimonial-expand-reader" value="Ada Cole" aria-label="Ada Cole" aria-describedby="demo-testimonial-expand-quote-4" >
      <div class="mu-voice-story">
        <div class="mu-voice-meta" aria-hidden="true">
          <svg width="32" height="26" viewBox="0 0 32 26" fill="currentColor" focusable="false"><path d="M1 25v-9C1 8 5 3 13 1v4c-4 2-6 5-6 9h6v11H1Zm17 0v-9c0-8 4-13 12-15v4c-4 2-6 5-6 9h6v11H18Z"/></svg>
          <span class="mu-voice-count"> / 06</span>
        </div>
        <blockquote id="demo-testimonial-expand-quote-4">I sent a contact sheet with one frame circled. They built a whole spread around the light in that frame.</blockquote>
      </div>
      <label for="demo-testimonial-expand-voice-4" class="mu-voice-author">
        <span class="mu-voice-photo" aria-hidden="true">
  <span>AC</span><img src="../components/portraits/ada-cole.webp" width="48" height="48" alt="" loading="lazy" decoding="async">
</span>
        <span class="mu-voice-credit"><strong>Ada Cole</strong><span class="mu-voice-role">Photographer</span></span>
        <span class="mu-voice-stars" data-rating="5" role="img" aria-label="5 out of 5 stars"></span>
      </label>
    </div>
    
    <div class="mu-voice-card">
      <input type="radio" class="mu-sr-only mu-voice-radio" id="demo-testimonial-expand-voice-5" name="demo-testimonial-expand-reader" value="Theo Park" aria-label="Theo Park" aria-describedby="demo-testimonial-expand-quote-5" >
      <div class="mu-voice-story">
        <div class="mu-voice-meta" aria-hidden="true">
          <svg width="32" height="26" viewBox="0 0 32 26" fill="currentColor" focusable="false"><path d="M1 25v-9C1 8 5 3 13 1v4c-4 2-6 5-6 9h6v11H1Zm17 0v-9c0-8 4-13 12-15v4c-4 2-6 5-6 9h6v11H18Z"/></svg>
          <span class="mu-voice-count"> / 06</span>
        </div>
        <blockquote id="demo-testimonial-expand-quote-5">My favorite detail is the spine. You can find this book on a crowded shelf from across the room.</blockquote>
      </div>
      <label for="demo-testimonial-expand-voice-5" class="mu-voice-author">
        <span class="mu-voice-photo" aria-hidden="true">
  <span>TP</span><img src="../components/portraits/theo-park.webp" width="48" height="48" alt="" loading="lazy" decoding="async">
</span>
        <span class="mu-voice-credit"><strong>Theo Park</strong><span class="mu-voice-role">Book designer</span></span>
        <span class="mu-voice-stars" data-rating="5" role="img" aria-label="5 out of 5 stars"></span>
      </label>
    </div>
    
  </div>
  
</section>
Go template
Go template
{{define "voice-photo"}}{{if or .Initials .ImageURL}}<span class="mu-voice-photo" aria-hidden="true">
  <span>{{.Initials}}</span>{{with .ImageURL}}<img src="{{.}}" width="48" height="48" alt="" loading="lazy" decoding="async">{{end}}
</span>{{end}}{{end}}
<section id="{{.ID}}" data-mono="testimonial-expand" aria-label="{{or .Label "Testimonials"}}">
  {{with .Items}}
  <div class="mu-voice-deck{{if gt (len .) 6}} mu-voice-stack{{end}}" role="radiogroup" aria-label="{{or $.Label "Testimonials"}}" style="--voice-count: {{len .}}">
    {{range $i, $item := .}}
    <div class="mu-voice-card">
      <input type="radio" class="mu-sr-only mu-voice-radio" id="{{$.ID}}-voice-{{$i}}" name="{{$.ID}}-reader" value="{{.Name}}" aria-label="{{.Name}}" aria-describedby="{{$.ID}}-quote-{{$i}}" {{if eq $i 0}}checked{{end}}>
      <div class="mu-voice-story">
        <div class="mu-voice-meta" aria-hidden="true">
          <svg width="32" height="26" viewBox="0 0 32 26" fill="currentColor" focusable="false"><path d="M1 25v-9C1 8 5 3 13 1v4c-4 2-6 5-6 9h6v11H1Zm17 0v-9c0-8 4-13 12-15v4c-4 2-6 5-6 9h6v11H18Z"/></svg>
          <span class="mu-voice-count"> / {{printf "%02d" (len $.Items)}}</span>
        </div>
        <blockquote id="{{$.ID}}-quote-{{$i}}">{{.Quote}}</blockquote>
      </div>
      <label for="{{$.ID}}-voice-{{$i}}" class="mu-voice-author">
        {{template "voice-photo" .}}
        <span class="mu-voice-credit"><strong>{{.Name}}</strong>{{with .Role}}<span class="mu-voice-role">{{.}}</span>{{end}}</span>
        {{with .Rating}}<span class="mu-voice-stars" data-rating="{{.}}" role="img" aria-label="{{.}} out of 5 stars"></span>{{end}}
      </label>
    </div>
    {{end}}
  </div>
  {{else}}<p class="mu-voice-empty">No testimonials yet.</p>{{end}}
</section>
Component CSS
Component CSS
[data-mono="testimonial-expand"] {
  container-type: inline-size;
  width: 100%;
  padding: clamp(.75rem, 3%, 1.5rem);
  border-radius: .9rem;
  background: #101010;
  color: #f3f3f3;
}
.mu-voice-deck {
  --voice-gap: .3rem;
  --voice-rail: clamp(2.75rem, 6.8cqi, 3rem);
  --voice-width: calc(100cqi - (var(--voice-count) - 1) * (var(--voice-rail) + var(--voice-gap)));
  display: flex;
  flex-direction: column;
  gap: var(--voice-gap);
  counter-reset: voice;
}
.mu-voice-card {
  --paper: #eaeaea;
  --ink: #171717;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  color: var(--ink);
  border-radius: 1.5rem;
  overflow: clip;
  counter-increment: voice;
}
.mu-voice-card:nth-child(6n + 2) { --paper: #4a4a4a; --ink: #fff; }
.mu-voice-card:nth-child(6n + 3) { --paper: #d2d2d2; }
.mu-voice-card:nth-child(6n + 4) { --paper: #656565; --ink: #fff; }
.mu-voice-card:nth-child(6n + 5) { --paper: #f4f4f4; }
.mu-voice-card:nth-child(6n + 6) { --paper: #373737; --ink: #fff; }
.mu-voice-card:has(:checked) { border-radius: .85rem; }
.mu-voice-card:has(:focus-visible) { outline: 2px solid #fff; outline-offset: 2px; z-index: 1; }

.mu-voice-story { display: none; }
.mu-voice-radio:checked ~ .mu-voice-story {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  padding: 1.2rem 1.15rem 1.8rem;
}
.mu-voice-meta { display: flex; justify-content: space-between; align-items: start; }
.mu-voice-count { font: .69rem/1.3 ui-monospace, monospace; font-variant-numeric: tabular-nums; opacity: .75; }
.mu-voice-count::before { content: counter(voice, decimal-leading-zero); }
.mu-voice-story blockquote {
  margin: 0;
  font-size: clamp(1.45rem, 4.25cqi, 2.1rem);
  line-height: 1.12;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.mu-voice-author {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 2.85rem;
  padding: .33rem .5rem;
  font-size: .9rem;
  cursor: pointer;
}
.mu-voice-photo {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font: 600 .7rem/1 ui-monospace, monospace;
}
.mu-voice-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); }
.mu-voice-photo:not(:has(img)):has(> span:empty) { display: none; }
.mu-voice-credit { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.mu-voice-credit strong { display: block; font-weight: 600; }
.mu-voice-role, .mu-voice-stars { display: none; }
.mu-voice-radio:checked ~ .mu-voice-author {
  margin: 0 1.15rem;
  padding: .8rem 0 .95rem;
  border-top: 1px solid currentColor;
  border-color: color-mix(in srgb, currentColor 28%, transparent);
}
.mu-voice-radio:checked ~ label .mu-voice-photo { width: 2.75rem; height: 2.75rem; border-radius: .5rem; }
.mu-voice-radio:checked ~ label .mu-voice-role { display: block; margin-top: .12rem; font-size: .75rem; opacity: .8; }
.mu-voice-radio:checked ~ label .mu-voice-stars {
  display: block;
  flex: none;
  margin-inline-start: auto;
  width: 3.25rem;
  height: .75rem;
  background: linear-gradient(to right, currentColor var(--rated, 100%), color-mix(in srgb, currentColor 25%, transparent) 0);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2.4 2.9 6.2 6.8 1-4.9 4.8 1.2 6.8-6-3.2-6 3.2 1.2-6.8-4.9-4.8 6.8-1z'/%3E%3C/svg%3E") left center / 20% 100% repeat-x;
}
.mu-voice-stars[data-rating="1"] { --rated: 20%; }
.mu-voice-stars[data-rating="2"] { --rated: 40%; }
.mu-voice-stars[data-rating="3"] { --rated: 60%; }
.mu-voice-stars[data-rating="4"] { --rated: 80%; }
.mu-voice-empty { padding: 1rem; }

@container (min-width: 34rem) {
  .mu-voice-deck:not(.mu-voice-stack) { flex-direction: row; min-height: clamp(20rem, 55cqi, 26rem); }
  .mu-voice-deck:not(.mu-voice-stack) .mu-voice-card {
    flex: 0 0 var(--voice-rail);
    margin-block: 1.55rem;
  }
  .mu-voice-deck:not(.mu-voice-stack) .mu-voice-card:has(:checked) {
    flex-basis: var(--voice-width);
    margin-block: 0;
  }
  .mu-voice-deck:not(.mu-voice-stack) .mu-voice-story { width: var(--voice-width); }
  .mu-voice-deck:not(.mu-voice-stack) .mu-voice-radio:checked ~ label { width: calc(var(--voice-width) - 2.3rem); }
  .mu-voice-deck:not(.mu-voice-stack) .mu-voice-radio:not(:checked) ~ label {
    flex: 1;
    flex-direction: column-reverse;
    gap: .5rem;
    width: var(--voice-rail);
    padding: .4rem .15rem;
  }
  .mu-voice-deck:not(.mu-voice-stack) .mu-voice-radio:not(:checked) ~ label .mu-voice-credit {
    display: grid;
    flex: 1;
    place-items: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: .8rem;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .mu-voice-card { transition: flex-basis 320ms cubic-bezier(.2,.8,.2,1), margin 320ms ease, border-radius 240ms ease; }
  .mu-voice-radio:checked ~ .mu-voice-story { animation: mu-voice-reveal 280ms ease-out both; }
  @keyframes mu-voice-reveal { from { opacity: 0; transform: translateY(.4rem); } }
}
@media (forced-colors: active) {
  .mu-voice-card { border: 1px solid ButtonText; }
  .mu-voice-card:has(:focus-visible) { outline-color: Highlight; }
  .mu-voice-stars { forced-color-adjust: none; color: CanvasText; }
}
JavaScript module
JavaScript module
export function mount(root) {
  const deck = root.querySelector('.mu-voice-deck');
  if (!deck) return;

  // Mouse exploration keeps the last quote open. Touch and keyboard use the native radios.
  deck.addEventListener('pointermove', event => {
    if (event.pointerType !== 'mouse' || event.buttons) return;
    const card = event.target.closest('.mu-voice-card');
    if (!card || card.closest('.mu-voice-deck') !== deck) return;
    const radio = card.querySelector('.mu-voice-radio');
    if (radio.checked || getComputedStyle(deck).flexDirection !== 'row') return;
    radio.checked = true;
    if (deck.contains(document.activeElement)) radio.focus({ preventScroll: true });
  });

  for (const image of deck.querySelectorAll('.mu-voice-photo img')) {
    if (image.complete && !image.naturalWidth) image.remove();
    else image.addEventListener('error', () => image.remove(), { once: true });
  }
}
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="./testimonial-expand.css">
<script type="module" src="./testimonial-expand.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 testimonial-expand
Example properties (JSON)
example.json
{
  "Items": [
    {
      "ImageURL": "../components/portraits/bea-lin.webp",
      "Initials": "BL",
      "Name": "Bea Lin",
      "Quote": "We pinned the first proof above the press. By Friday, half the studio had asked for a copy.",
      "Rating": 5,
      "Role": "Art director"
    },
    {
      "ImageURL": "../components/portraits/ellis-reed.webp",
      "Initials": "ER",
      "Name": "Ellis Reed",
      "Quote": "The lowercase g took three rounds. Seeing it on the finished cover made every one of them worth it.",
      "Rating": 5,
      "Role": "Type designer"
    },
    {
      "ImageURL": "../components/portraits/mira-shah.webp",
      "Initials": "MS",
      "Name": "Mira Shah",
      "Quote": "They left just enough white space for the quietest line in the essay to land.",
      "Rating": 4,
      "Role": "Editor"
    },
    {
      "ImageURL": "../components/portraits/felix-hart.webp",
      "Initials": "FH",
      "Name": "Felix Hart",
      "Quote": "There’s a little grain at the edge of the black. I’m glad we kept it. You can tell a person pulled that print.",
      "Rating": 5,
      "Role": "Printmaker"
    },
    {
      "ImageURL": "../components/portraits/ada-cole.webp",
      "Initials": "AC",
      "Name": "Ada Cole",
      "Quote": "I sent a contact sheet with one frame circled. They built a whole spread around the light in that frame.",
      "Rating": 5,
      "Role": "Photographer"
    },
    {
      "ImageURL": "../components/portraits/theo-park.webp",
      "Initials": "TP",
      "Name": "Theo Park",
      "Quote": "My favorite detail is the spine. You can find this book on a crowded shelf from across the room.",
      "Rating": 5,
      "Role": "Book designer"
    }
  ],
  "Label": "Studio notes"
}