Marketing sectionsServicesAccordion
Searchastronomic.dev# ServicesAccordion
For a numbered list of what you do, each opening to show what it includes, the work, and a link.
Static: no JavaScript.
## Usage
```astro
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
```
## Examples
### A numbered accordion
Each row: the number, the title and the chevron. From a 48rem list an open service's body sits under its title, the text beside the tags, then the photo across both and the link.
```astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
// Your own image file.
import sketching from "../../photos/sketching-wireframes.webp";
const services = [
{
title: "Brand identity",
text: "Positioning, logo and type systems, a voice your team can write in, and guidelines people actually open.",
tags: ["Strategy workshops", "Wordmark", "Type and color", "Guidelines"],
link: { label: "How we work on brands", href: "#brand" },
},
{
title: "Websites",
text: "Marketing sites designed and built in Astro: fast by default, easy for your team to edit, and handed over with source and docs.",
image: { src: sketching, alt: "A hand sketching page wireframes beside a mug." },
tags: ["Content and UX", "Design", "Astro build", "CMS setup"],
},
{
title: "Design systems",
text: "Components, tokens and plain-language docs that keep the brand consistent long after the handover.",
tags: ["Tokens", "Components", "Docs site"],
},
];
---
<Container class="py-16">
<ServicesAccordion heading="Services" mark="(3)" markLabel="3 services" text="Three things, done by the same small team." items={services} openFirst />
</Container>
```
### On the dark panel
tone="inverse" inside Panel tone="inverse": the panel's colors, and its mark color for the open number.
```astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import Panel from "@astronomic-dev/ui/components/Panel.astro";
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
const services = [
{ title: "Brand identity", text: "Positioning, logo and type systems, and guidelines people actually open.", tags: ["Wordmark", "Type and color", "Guidelines"], link: { label: "How we work on brands", href: "#brand" } },
{ title: "Websites", text: "Marketing sites built in Astro, easy for your team to edit.", tags: ["Design", "Astro build", "CMS setup"] },
{ title: "Motion and film", text: "Logo animation, product films and a motion kit for every social post.", tags: ["Logo motion", "Product film"] },
];
---
<!-- On the dark panel: tone="inverse" names the panel's colors; the open number takes the panel's mark color. -->
<Panel tone="inverse" as="div">
<Container>
<ServicesAccordion tone="inverse" heading="Services" mark="(3)" markLabel="3 services" items={services} openFirst>
<span slot="eyebrow" class="text-small text-on-inverse-muted">(004) What we do</span>
</ServicesAccordion>
</Container>
</Panel>
```
### One open at a time
With exclusive, opening a service closes the one that was open. The browser does it; no script.
```astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
const services = [
{ title: "Brand identity", text: "Positioning, logo and type systems.", tags: ["Wordmark", "Guidelines"] },
{ title: "Websites", text: "Marketing sites built in Astro.", tags: ["Design", "Astro build"] },
{ title: "Campaigns", text: "Launch campaigns, photo direction and print.", tags: ["Art direction", "Print"] },
];
---
<!-- One service open at a time: opening one closes the others, natively, with no script. -->
<Container class="py-16">
<ServicesAccordion heading="What we do" items={services} exclusive openFirst />
</Container>
```
### A long title in a narrow column
In a 20rem column the number sits above the title, a long title wraps beside the chevron, and the body stacks.
```astro
---
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
const services = [
{ title: "Accessibility reviews and remediation", text: "An audit against WCAG 2.2, then the fixes, built and tested with your team.", tags: ["Audit", "Fixes", "Training"] },
{ title: "Internationalization", text: "Sites in several languages, right to left included.", tags: ["Locales", "Translation workflow"] },
];
---
<!-- In a 20rem column: the number sits above the title, a long title wraps beside the chevron, and the body stacks. -->
<div class="max-w-xs">
<ServicesAccordion heading="Services" items={services} openFirst />
</div>
```
## Props
### ServicesAccordion
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `ServiceEntry[]` | None | Required. One or more services, numbered from (01) in this order: { title, text?, image?, tags?, link? }. Only these fields reach the markup. Empty throws. |
| `numberFormat` | `"paren" \| "slash"` | `"paren"` | How the services' numbers show: paren, "(01)", or slash, "01 /" (the slash in the number's own type and color). |
| `heading` | `string` | None | The section heading. Without it there is no section and no header: a <div> holds only the services. |
| `emphasis` | `boolean` | `false` | Turn one *phrase* in the heading into <em>. |
| `mark` | `string` | None | A short mark after the heading, such as "(5)". Shown only with a heading. |
| `markLabel` | `string` | None | What the mark says to a screen reader, such as "5 services". Without it, the mark is read as written. |
| `text` | `string` | None | One or two sentences under the heading. Shown only with a heading. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The section heading's element. Each title sits one level under it. |
| `itemHeadingTag` | `"h2" \| "h3" \| "h4" \| "h5"` | `"h3"` | The titles' element when there is no heading. |
| `exclusive` | `boolean` | `false` | One service open at a time: opening one closes the others (native, no script). Each list gets its own group. |
| `openFirst` | `boolean` | `false` | Open the first service on load. |
| `tone` | `"page" \| "inverse"` | `"page"` | The surface it sits on. inverse: on Panel tone="inverse": the header, the rows and the focus ring take the panel's colors. |
| `imageComponent` | `ImageComponent` | None | Your image component for every service's photo (Media's imageComponent). |
| `imageSizes` | `string` | None | How wide each photo shows, for imageComponent's sizes. |
| `class` | `string` | None | More classes on the root, merged with cn(), so yours win on conflicts. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short label above the heading. Shown only with a heading. |
Any other attribute goes on the root (<section>, or <div> without a heading).
## Accessibility
- With a heading, renders a <section> named by it, so it is a region landmark. The heading id is unique on the page. Without one, a plain <div>: put your own heading above it.
- Each service is a native <details> and <summary>, so the keyboard and screen readers work without any script: Enter or Space opens and closes it.
- The summary's name is the service's title: the number and the chevron are hidden from screen readers. The title is a heading one level under the section heading.
- Every summary is at least 44px tall, so it is easy to tap. The link in the body is a 44px box on touch.
- Safari with VoiceOver reads a summary as one button and may flatten what is inside it, so the titles may not show in its heading list. They are still reached as buttons.
- Open, the chevron points up. It turns smoothly only when the reader allows motion and the theme is not calm; otherwise it flips at once.
ServicesAccordion
ProFor a numbered list of what you do, each opening to show what it includes, the work, and a link.
- File
- ServicesAccordion.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 4
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
A numbered accordion
Each row: the number, the title and the chevron. From a 48rem list an open service's body sits under its title, the text beside the tags, then the photo across both and the link.
This preview did not load.
examples/servicesaccordion/main.astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
// Your own image file.
import sketching from "../../photos/sketching-wireframes.webp";
const services = [
{
title: "Brand identity",
text: "Positioning, logo and type systems, a voice your team can write in, and guidelines people actually open.",
tags: ["Strategy workshops", "Wordmark", "Type and color", "Guidelines"],
link: { label: "How we work on brands", href: "#brand" },
},
{
title: "Websites",
text: "Marketing sites designed and built in Astro: fast by default, easy for your team to edit, and handed over with source and docs.",
image: { src: sketching, alt: "A hand sketching page wireframes beside a mug." },
tags: ["Content and UX", "Design", "Astro build", "CMS setup"],
},
{
title: "Design systems",
text: "Components, tokens and plain-language docs that keep the brand consistent long after the handover.",
tags: ["Tokens", "Components", "Docs site"],
},
];
---
<Container class="py-16">
<ServicesAccordion heading="Services" mark="(3)" markLabel="3 services" text="Three things, done by the same small team." items={services} openFirst />
</Container>On the dark panel
tone="inverse" inside Panel tone="inverse": the panel's colors, and its mark color for the open number.
This preview did not load.
examples/servicesaccordion/inverse.astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import Panel from "@astronomic-dev/ui/components/Panel.astro";
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
const services = [
{ title: "Brand identity", text: "Positioning, logo and type systems, and guidelines people actually open.", tags: ["Wordmark", "Type and color", "Guidelines"], link: { label: "How we work on brands", href: "#brand" } },
{ title: "Websites", text: "Marketing sites built in Astro, easy for your team to edit.", tags: ["Design", "Astro build", "CMS setup"] },
{ title: "Motion and film", text: "Logo animation, product films and a motion kit for every social post.", tags: ["Logo motion", "Product film"] },
];
---
<!-- On the dark panel: tone="inverse" names the panel's colors; the open number takes the panel's mark color. -->
<Panel tone="inverse" as="div">
<Container>
<ServicesAccordion tone="inverse" heading="Services" mark="(3)" markLabel="3 services" items={services} openFirst>
<span slot="eyebrow" class="text-small text-on-inverse-muted">(004) What we do</span>
</ServicesAccordion>
</Container>
</Panel>One open at a time
With exclusive, opening a service closes the one that was open. The browser does it; no script.
This preview did not load.
examples/servicesaccordion/exclusive.astro
---
import Container from "@astronomic-dev/ui/components/Container.astro";
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
const services = [
{ title: "Brand identity", text: "Positioning, logo and type systems.", tags: ["Wordmark", "Guidelines"] },
{ title: "Websites", text: "Marketing sites built in Astro.", tags: ["Design", "Astro build"] },
{ title: "Campaigns", text: "Launch campaigns, photo direction and print.", tags: ["Art direction", "Print"] },
];
---
<!-- One service open at a time: opening one closes the others, natively, with no script. -->
<Container class="py-16">
<ServicesAccordion heading="What we do" items={services} exclusive openFirst />
</Container>A long title in a narrow column
In a 20rem column the number sits above the title, a long title wraps beside the chevron, and the body stacks.
This preview did not load.
examples/servicesaccordion/long-title.astro
---
import ServicesAccordion from "@astronomic/ui-pro/components/ServicesAccordion.astro";
const services = [
{ title: "Accessibility reviews and remediation", text: "An audit against WCAG 2.2, then the fixes, built and tested with your team.", tags: ["Audit", "Fixes", "Training"] },
{ title: "Internationalization", text: "Sites in several languages, right to left included.", tags: ["Locales", "Translation workflow"] },
];
---
<!-- In a 20rem column: the number sits above the title, a long title wraps beside the chevron, and the body stacks. -->
<div class="max-w-xs">
<ServicesAccordion heading="Services" items={services} openFirst />
</div>