Strategy
We learn your clients, your offer, and what the site must do.
Data displayCard
Searchastronomic.dev# Card
To group a short piece of content, like a service, a plan or a team member.
Static: no JavaScript.
## Usage
```astro
import Card from "@astronomic-dev/ui/components/Card.astro";
```
## Examples
### Service cards
```astro
---
import Card from "@astronomic-dev/ui/components/Card.astro";
const services = [
{ title: "Strategy", text: "We learn your clients, your offer, and what the site must do." },
{ title: "Design", text: "A clear look that fits your firm, tested on real content." },
{ title: "Build", text: "Fast pages, easy editing, and clean handover." },
];
---
<div class="grid gap-5 sm:grid-cols-3">
{
services.map((s) => (
<Card as="article">
<h3 class="m-0 text-lg font-semibold">{s.title}</h3>
<p class="m-0 text-[0.9375rem] text-muted">{s.text}</p>
</Card>
))
}
</div>
```
### With an image
image puts a Media at the top of the card.
```astro
---
import Card from "@astronomic-dev/ui/components/Card.astro";
// Your own image files.
import plants from "../../photos/plants-shelf.webp";
import stairway from "../../photos/white-stairway.webp";
import concrete from "../../photos/concrete-slab.webp";
const projects = [
{ title: "Greenhouse café", text: "A menu site that the owners update every morning.", image: { src: plants, alt: "" } },
{ title: "Atrium offices", text: "Floor plans and leasing, in one quiet page.", image: { src: stairway, alt: "" } },
{ title: "Civic library", text: "Events, rooms and opening hours for a new branch.", image: { src: concrete, alt: "" } },
];
---
<div class="grid gap-5 sm:grid-cols-3">
{
projects.map((p) => (
<Card as="article" image={p.image}>
<h3 class="m-0 text-lg font-semibold">{p.title}</h3>
<p class="m-0 text-[0.9375rem] text-muted">{p.text}</p>
</Card>
))
}
</div>
```
### Slots
The card is a shell: media, header, the body and footer always show in that order, and the footer sits on the bottom edge when cards in a row stretch. CardMedia, CardSide and CardOverlay are recipes built on it.
```astro
---
import Button from "@astronomic-dev/ui/components/Button.astro";
import Card from "@astronomic-dev/ui/components/Card.astro";
import Media from "@astronomic-dev/ui/components/Media.astro";
// Your own image files.
import desk from "../../photos/studio-desk.webp";
import notebook from "../../photos/leather-notebook.webp";
const offers = [
{ name: "Brand sprint", text: "Two weeks to a name, a logo and a short style guide.", image: desk, cta: "Book a sprint" },
{ name: "Site care", text: "Monthly updates, checks and small changes, with a report.", image: notebook, cta: "Ask about care" },
];
---
<div class="grid gap-5 sm:grid-cols-2">
{
offers.map((o) => (
<Card as="article">
<Media slot="media" src={o.image} alt="" ratio="16/9" />
<Fragment slot="header">
<p class="m-0 text-eyebrow font-medium text-muted">Service</p>
<h3 class="m-0 text-heading font-semibold">{o.name}</h3>
</Fragment>
<p class="m-0 text-body text-muted">{o.text}</p>
<Button slot="footer" href="#contact" variant="secondary">{o.cta}</Button>
</Card>
))
}
</div>
```
## Props
### Card
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `as` | `HTMLTag` | `"div"` | The element to render, such as article or li. |
| `featured` | `boolean` | `false` | Highlights the card with an accent border, for example the recommended plan. It also sets data-featured on the card, a hook your own CSS can style (a heavier frame, a fill) where the accent is close to the border. |
| `image` | `MediaImage` | None | An image at the top, inside the padding. MediaImage is { src, alt, width?, height?, ratio?, loading?, focalPoint? }, Media's props; the ratio defaults to 16/9. The media slot wins over it. |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. |
| Slot | Description |
| --- | --- |
| `media` | An image or other media at the top, at the card's image inset. Takes the place of image. |
| `header` | An eyebrow and the title, kept close together, under the media. |
| `default` | The card's content, under the header. Its children sit straight in the card's column, so the card's gap spaces them. |
| `footer` | Links or buttons, last. It takes the free height above it, so in a row of stretched cards every footer lines up at the bottom. |
Any other attribute goes on the rendered element.
## Accessibility
- Renders a plain <div> with no role, so it adds nothing for a screen reader.
- Use as to pick a fitting element, such as article or li, and keep headings inside it in page order.
- featured is only a border, so say in text why a card stands out.
- An image needs alt like any Media. When the card's heading already says it all, use alt="".
- The shell sets the order of its slots, so the reading order is always media, header, body, footer, whatever order you write them in.
To group a short piece of content, like a service, a plan or a team member.
Drag the orange handle to set the width. Frames get real breakpoints.
We learn your clients, your offer, and what the site must do.
A clear look that fits your firm, tested on real content.
Fast pages, easy editing, and clean handover.
examples/card/main.astro
---
import Card from "@astronomic-dev/ui/components/Card.astro";
const services = [
{ title: "Strategy", text: "We learn your clients, your offer, and what the site must do." },
{ title: "Design", text: "A clear look that fits your firm, tested on real content." },
{ title: "Build", text: "Fast pages, easy editing, and clean handover." },
];
---
<div class="grid gap-5 sm:grid-cols-3">
{
services.map((s) => (
<Card as="article">
<h3 class="m-0 text-lg font-semibold">{s.title}</h3>
<p class="m-0 text-[0.9375rem] text-muted">{s.text}</p>
</Card>
))
}
</div>image puts a Media at the top of the card.

A menu site that the owners update every morning.

Floor plans and leasing, in one quiet page.

Events, rooms and opening hours for a new branch.
examples/card/image.astro
---
import Card from "@astronomic-dev/ui/components/Card.astro";
// Your own image files.
import plants from "../../photos/plants-shelf.webp";
import stairway from "../../photos/white-stairway.webp";
import concrete from "../../photos/concrete-slab.webp";
const projects = [
{ title: "Greenhouse café", text: "A menu site that the owners update every morning.", image: { src: plants, alt: "" } },
{ title: "Atrium offices", text: "Floor plans and leasing, in one quiet page.", image: { src: stairway, alt: "" } },
{ title: "Civic library", text: "Events, rooms and opening hours for a new branch.", image: { src: concrete, alt: "" } },
];
---
<div class="grid gap-5 sm:grid-cols-3">
{
projects.map((p) => (
<Card as="article" image={p.image}>
<h3 class="m-0 text-lg font-semibold">{p.title}</h3>
<p class="m-0 text-[0.9375rem] text-muted">{p.text}</p>
</Card>
))
}
</div>The card is a shell: media, header, the body and footer always show in that order, and the footer sits on the bottom edge when cards in a row stretch. CardMedia, CardSide and CardOverlay are recipes built on it.

Service
Two weeks to a name, a logo and a short style guide.

Service
Monthly updates, checks and small changes, with a report.
examples/card/slots.astro
---
import Button from "@astronomic-dev/ui/components/Button.astro";
import Card from "@astronomic-dev/ui/components/Card.astro";
import Media from "@astronomic-dev/ui/components/Media.astro";
// Your own image files.
import desk from "../../photos/studio-desk.webp";
import notebook from "../../photos/leather-notebook.webp";
const offers = [
{ name: "Brand sprint", text: "Two weeks to a name, a logo and a short style guide.", image: desk, cta: "Book a sprint" },
{ name: "Site care", text: "Monthly updates, checks and small changes, with a report.", image: notebook, cta: "Ask about care" },
];
---
<div class="grid gap-5 sm:grid-cols-2">
{
offers.map((o) => (
<Card as="article">
<Media slot="media" src={o.image} alt="" ratio="16/9" />
<Fragment slot="header">
<p class="m-0 text-eyebrow font-medium text-muted">Service</p>
<h3 class="m-0 text-heading font-semibold">{o.name}</h3>
</Fragment>
<p class="m-0 text-body text-muted">{o.text}</p>
<Button slot="footer" href="#contact" variant="secondary">{o.cta}</Button>
</Card>
))
}
</div>