Data displayServiceItem
Searchastronomic.dev# ServiceItem
For one service in a ServicesList: its number, title, text, photo, tags and a link. The services recipes use it for you.
Static: no JavaScript.
## Usage
```astro
import ServiceItem from "@astronomic/ui-pro/components/ServiceItem.astro";
```
## Examples
### One service
One numbered row: the number, the title and the chevron in the summary; open, the text, the tags and one link. childHeadingTag() in lib/heading.ts gives the title's level. In a ServicesList the shell numbers the rows and passes each one's level and group for you.
```astro
---
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import ServiceItem from "@astronomic/ui-pro/components/ServiceItem.astro";
const tag = childHeadingTag({ heading: "Services" });
---
<!-- One service on its own. In a ServicesList each row reads the list's services container; here the wrapper is one. -->
<div class="@container/services mx-auto max-w-3xl">
<ServiceItem
number="(01)"
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", "Guidelines"]}
link={{ label: "How we work on brands", href: "#brand" }}
headingTag={tag}
open
/>
<ServiceItem number="(02)" title="Websites" text="Marketing sites built in Astro." headingTag={tag} />
</div>
```
## Props
### ServiceItem
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | None | Required. The service's name, the summary's heading and the control's name. |
| `headingTag` | `"h2" \| "h3" \| "h4" \| "h5"` | None | Required. The title's element: one level under the section heading (childHeadingTag() in lib/heading.ts). |
| `number` | `string` | None | A short number before the title, such as "(01)". Hidden from screen readers. |
| `text` | `string` | None | What the service includes, in a sentence or two, at the running-text width. |
| `image` | `MediaImage` | None | A photo of the work in the body (Media; the ratio defaults to 3/2). Write its alt. |
| `imageComponent` | `ImageComponent` | None | Your image component for the photo (Media's imageComponent). |
| `imageSizes` | `string` | None | How wide the photo shows, for imageComponent's sizes. |
| `tags` | `string[]` | `[]` | Short labels for what is included, shown as quiet outlined pills. |
| `link` | `ServiceLink` | None | One link at the end of the body: { label, href }. |
| `open` | `boolean` | `false` | Open on load. |
| `name` | `string` | None | The group: services that share a name open one at a time (the browser does it). |
| `tone` | `"page" \| "inverse"` | `"page"` | The surface it sits on. inverse: on Panel tone="inverse", with the panel's colors, its mark color for the open number, and its focus ring. |
| `bodyClass` | `string` | None | For recipes: the body (text, photo, tags and link), such as its columns. |
| `class` | `string` | None | More classes on the <details>, merged with cn(), so yours win on conflicts. |
Any other attribute goes on the <details>.
## Accessibility
- 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.
ServiceItem
ProFor one service in a ServicesList: its number, title, text, photo, tags and a link. The services recipes use it for you.
- File
- ServiceItem.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
One service
One numbered row: the number, the title and the chevron in the summary; open, the text, the tags and one link. childHeadingTag() in lib/heading.ts gives the title's level. In a ServicesList the shell numbers the rows and passes each one's level and group for you.
Brand identity
Positioning, logo and type systems, a voice your team can write in, and guidelines people actually open.
- Strategy workshops
- Wordmark
- Guidelines
Websites
Marketing sites built in Astro.
Force statemain.astro
examples/serviceitem/main.astro
---
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import ServiceItem from "@astronomic/ui-pro/components/ServiceItem.astro";
const tag = childHeadingTag({ heading: "Services" });
---
<!-- One service on its own. In a ServicesList each row reads the list's services container; here the wrapper is one. -->
<div class="@container/services mx-auto max-w-3xl">
<ServiceItem
number="(01)"
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", "Guidelines"]}
link={{ label: "How we work on brands", href: "#brand" }}
headingTag={tag}
open
/>
<ServiceItem number="(02)" title="Websites" text="Marketing sites built in Astro." headingTag={tag} />
</div>Minimal · Light