Data displayTestimonial
Searchastronomic.dev# Testimonial
For one quote in a Testimonials section: the words, the person, an avatar and a logo. The testimonial recipes use it for you.
Static: no JavaScript.
## Usage
```astro
import Testimonial from "@astronomic-dev/ui/components/Testimonial.astro";
```
## Examples
### In a Testimonials list
Two quotes, each a Testimonial in an <li>: one with a title and a logo, one without an avatar. The testimonial recipes build their quotes from it, so you only need it for your own layout.
```astro
---
import Testimonial from "@astronomic-dev/ui/components/Testimonial.astro";
import Testimonials from "@astronomic-dev/ui/components/Testimonials.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Star from "../../logos/astronomic-star.svg";
const heading = "What clients say";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Testimonials heading={heading} listClass="gap-5 @3xl/testimonials:grid-cols-2">
<li class="grid min-w-0">
<Testimonial
title="With a title and a logo"
quote="A short title above the quote, initials in place of a photo, and a company mark at the end of the caption."
name="Sample Person"
role="Head of brand"
company="Sample Co."
headingTag={tag}
>
<Star slot="logo" class="size-6 text-muted" aria-hidden="true" />
</Testimonial>
</li>
<li class="grid min-w-0">
<Testimonial
quote="With avatar={false}, the caption is the name and the byline alone."
name="Sample Person"
role="Editor"
company="Sample Co."
avatar={false}
headingTag={tag}
/>
</li>
</Testimonials>
</div>
```
## Props
### Testimonial
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `quote` | `string` | None | Required. The words, as plain text. |
| `name` | `string` | None | Required. The person's name, first in the caption. |
| `role` | `string` | None | The person's role, after the name, muted. |
| `company` | `string` | None | The company, after the role, muted. |
| `meta` | `string[]` | None | Short facts about the person, shown in place of role and company, such as the town and the service: ["Oak Park", "Lawn care"] shows "Oak Park · Lawn care". The dots are hidden from a screen reader, which hears a comma. Empty entries are left out. |
| `avatar` | `UiImage \| false` | None | A photo of the person ({ src, alt, width?, height? }). Without it, initials show; `false` hides the avatar. |
| `title` | `string` | None | A short title above the quote, such as "Launched in three weeks", in the heading role. |
| `emphasis` | `boolean` | `false` | For recipes. Turn one *phrase* in the quote into <em>, by the heading rule (lib/emphasis.ts). TestimonialQuote sets it from its own emphasis. Off by default, so the quote shows as typed. |
| `headingTag` | `"h2" \| "h3" \| "h4" \| "h5"` | None | Required. The title element. Pass childHeadingTag({ heading, headingTag }) from lib/heading.ts, one level under the section heading. |
| `align` | `"start" \| "center"` | `"start"` | The alignment of the quote and the caption. |
| `tone` | `"page" \| "inverse"` | `"page"` | inverse on the inverse surface (Panel tone="inverse"): the name and byline in its colors. |
| `quoteClass` | `string` | None | For recipes. Classes for the quote, after its own, such as its type role and face: text-quote and display type for one large quote, text-lead text-pretty (the body face) on a card. Without it, the quote is body text in the body face. |
| `class` | `string` | None | More classes for the <figure>, merged with cn(), so yours win on conflicts. |
| Slot | Description |
| --- | --- |
| `head` | A line above the title and the quote (data-testimonial-head), such as a star rating and where the review came from. An empty slot leaves no box. |
| `avatar` | Your own image element in place of the Avatar. It sits in an aria-hidden box, since the name is written next to it, so put nothing focusable in it. |
| `logo` | A company mark at the end of the caption. When company is set, give an image alt="" (an inline SVG aria-hidden="true"): the caption already names the company. |
Any other attribute goes on the <figure>.
## Accessibility
- Renders one <figure>: put it in an <li> in a Testimonials list.
- The quote is a <blockquote> in the <figure>, its caption (<figcaption>) the person: the name, then the role and the company, or the meta facts. Between the facts, the dot is aria-hidden and a screen reader hears a comma.
- The avatar sits in an aria-hidden box, since the name is written next to it: an image slotted with alt text never reads the name twice. Put nothing focusable in it.
- In the logo slot, give an image alt="" when company is set: the caption already names the company.
- The title is the heading level you pass. Use childHeadingTag so it sits one level under the section heading.
Testimonial
FreeFor one quote in a Testimonials section: the words, the person, an avatar and a logo. The testimonial recipes use it for you.
- File
- Testimonial.astro
- Group
- Data display
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
In a Testimonials list
Two quotes, each a Testimonial in an <li>: one with a title and a logo, one without an avatar. The testimonial recipes build their quotes from it, so you only need it for your own layout.
What clients say
With a title and a logo
A short title above the quote, initials in place of a photo, and a company mark at the end of the caption.
Sample PersonHead of brand, Sample Co. With avatar={false}, the caption is the name and the byline alone.
Sample PersonEditor, Sample Co.
Force statemain.astro
examples/testimonial/main.astro
---
import Testimonial from "@astronomic-dev/ui/components/Testimonial.astro";
import Testimonials from "@astronomic-dev/ui/components/Testimonials.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Star from "../../logos/astronomic-star.svg";
const heading = "What clients say";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Testimonials heading={heading} listClass="gap-5 @3xl/testimonials:grid-cols-2">
<li class="grid min-w-0">
<Testimonial
title="With a title and a logo"
quote="A short title above the quote, initials in place of a photo, and a company mark at the end of the caption."
name="Sample Person"
role="Head of brand"
company="Sample Co."
headingTag={tag}
>
<Star slot="logo" class="size-6 text-muted" aria-hidden="true" />
</Testimonial>
</li>
<li class="grid min-w-0">
<Testimonial
quote="With avatar={false}, the caption is the name and the byline alone."
name="Sample Person"
role="Editor"
company="Sample Co."
avatar={false}
headingTag={tag}
/>
</li>
</Testimonials>
</div>Minimal · Light