
Real estate
Atrium offices
Floor plans and leasing, in one quiet page.
Data displayCardOverlay
Searchastronomic.dev# CardOverlay
For a short title on a large picture, like a featured project or a place, with the text on the dimmed image.
Static: no JavaScript.
## Usage
```astro
import CardOverlay from "@astronomic-dev/ui/components/CardOverlay.astro";
```
## Examples
### Text on the image
The image fills the card, dimmed by --ui-scrim, a dark ink in both modes. The scrim is heavier at the foot, where the text sits.
```astro
---
import CardOverlay from "@astronomic-dev/ui/components/CardOverlay.astro";
// Your own image files.
import stairway from "../../photos/white-stairway.webp";
import plants from "../../photos/plants-shelf.webp";
---
<div class="grid gap-5 sm:grid-cols-2">
<CardOverlay image={{ src: stairway, alt: "" }} eyebrow="Real estate" title="Atrium offices" text="Floor plans and leasing, in one quiet page." href="#atrium" />
<CardOverlay image={{ src: plants, alt: "" }} eyebrow="Hospitality" title="Greenhouse café" text="A menu site that the owners update every morning." href="#greenhouse" />
</div>
```
## Props
### CardOverlay
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `image` | `MediaImage` | None | The image behind the text. It fills the card and is cropped, so its `ratio` is not used; its focalPoint sets the part that stays in view. |
| `eyebrow` | `string` | None | A short line above the title, such as a place or a category. |
| `title` | `string` | None | The title. With href it is the link's text. |
| `text` | `string` | None | A line or two under the title. |
| `href` | `string` | None | Makes the whole card one link to this page. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h3"` | The title's element. Pick the level that fits the page outline. |
| `as` | `HTMLTag` | `"article"` | The element to render. Use li inside a list. |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. The card is at least 80 spacing units tall; a min-h class changes that. |
Any other attribute goes on the rendered element.
## Accessibility
- Renders an <article> by default, with the title as its heading at headingTag's level.
- The text is in --ui-scrim-fg on --ui-scrim at 60% or more (over a light veil on the whole image), so it reads at 4.5:1 or more on any image, black or white, in every kit preset, light and dark. A test checks it.
- With href the focus ring sits just inside the card's edge, since the card clips the image.
- With href, only the title is a link; its ::after covers the card, and the focus ring goes round the whole card.
- The image is behind the text, so it is often decoration: use alt="" unless it shows something the text does not say.
For a short title on a large picture, like a featured project or a place, with the text on the dimmed image.
Drag the orange handle to set the width. Frames get real breakpoints.
The image fills the card, dimmed by --ui-scrim, a dark ink in both modes. The scrim is heavier at the foot, where the text sits.

Real estate
Floor plans and leasing, in one quiet page.

Hospitality
A menu site that the owners update every morning.
examples/cardoverlay/main.astro
---
import CardOverlay from "@astronomic-dev/ui/components/CardOverlay.astro";
// Your own image files.
import stairway from "../../photos/white-stairway.webp";
import plants from "../../photos/plants-shelf.webp";
---
<div class="grid gap-5 sm:grid-cols-2">
<CardOverlay image={{ src: stairway, alt: "" }} eyebrow="Real estate" title="Atrium offices" text="Floor plans and leasing, in one quiet page." href="#atrium" />
<CardOverlay image={{ src: plants, alt: "" }} eyebrow="Hospitality" title="Greenhouse café" text="A menu site that the owners update every morning." href="#greenhouse" />
</div>