Publishing sectionsCaseGallery
Searchastronomic.dev# CaseGallery
For a case study's photos, two side by side or one per row, each with an optional caption.
Static: no JavaScript.
## Usage
```astro
import CaseGallery from "@astronomic/ui-pro/components/CaseGallery.astro";
```
## Examples
### Pairs
Two side by side from a 42rem gallery, each 4/3 unless it sets its own ratio; an odd last photo runs across both. A caption sits under its photo.
```astro
---
import CaseGallery from "@astronomic/ui-pro/components/CaseGallery.astro";
// Your own photos.
import desk from "../../photos/studio-desk.webp";
import plants from "../../photos/plants-shelf.webp";
import shelves from "../../photos/studio-shelves.webp";
// Your photos, in order. Write each alt; a caption is optional.
const images = [
{ src: shelves, alt: "Plates and bowls on white shelves.", caption: "The first release, as it came out of the kiln." },
{ src: plants, alt: "Two potted plants on a wooden shelf." },
{ src: desk, alt: "A laptop, a framed print and a cactus on a light wood desk.", caption: "The release notes are written at the studio desk." },
];
---
<!-- Two side by side from a 42rem gallery; the odd last photo runs across both. -->
<div class="mx-auto max-w-6xl px-6 py-10">
<CaseGallery images={images} />
</div>
```
### Full width
layout="full": one photo per row, each 16/9 unless it sets its own ratio.
```astro
---
import CaseGallery from "@astronomic/ui-pro/components/CaseGallery.astro";
// Your own photos.
import concrete from "../../photos/concrete-slab.webp";
import stairway from "../../photos/white-stairway.webp";
const images = [
{ src: concrete, alt: "A concrete building against a pale sky." },
{ src: stairway, alt: "A white stairwell seen from above.", caption: "The library's stair, where the new signs start." },
];
---
<!-- layout="full": one photo per row, each 16/9 unless it sets its own ratio. -->
<div class="mx-auto max-w-6xl px-6 py-10">
<CaseGallery images={images} layout="full" />
</div>
```
## Props
### CaseGallery
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `images` | `CaseGalleryImage[]` | None | Required, one or more (empty stops the build): { src, alt, width?, height?, ratio?, focalPoint?, loading?, caption? } (CaseGalleryImage, exported). Write each alt. Only these fields reach the markup. |
| `layout` | `"pairs" \| "full"` | `"pairs"` | pairs: two side by side from a 42rem gallery, an odd last one full width; full: one per row. |
| `imageComponent` | `ImageComponent` | None | Your image component, for every photo: Astro's <Image>, or a small wrapper for your CMS. |
| `imageSizes` | `string` | None | How wide each photo shows, as the sizes attribute, for your component's srcset. Default "(min-width: 48rem) 50vw, 100vw" for pairs, "100vw" for full. |
| `class` | `string` | None | More classes for the root <div>, merged with cn(). It is a named size container (case-gallery). |
Any other attribute goes on the root <div>.
## Accessibility
- Each photo is its own <figure>, with its caption as a <figcaption> when given.
- Write each photo's alt: a case study's photos are its content.
CaseGallery
ProFor a case study's photos, two side by side or one per row, each with an optional caption.
- File
- CaseGallery.astro
- Group
- Publishing sections
- Kind
- Static: no JavaScript
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Pairs
Two side by side from a 42rem gallery, each 4/3 unless it sets its own ratio; an odd last photo runs across both. A caption sits under its photo.
This preview did not load.
main.astro
examples/casegallery/main.astro
---
import CaseGallery from "@astronomic/ui-pro/components/CaseGallery.astro";
// Your own photos.
import desk from "../../photos/studio-desk.webp";
import plants from "../../photos/plants-shelf.webp";
import shelves from "../../photos/studio-shelves.webp";
// Your photos, in order. Write each alt; a caption is optional.
const images = [
{ src: shelves, alt: "Plates and bowls on white shelves.", caption: "The first release, as it came out of the kiln." },
{ src: plants, alt: "Two potted plants on a wooden shelf." },
{ src: desk, alt: "A laptop, a framed print and a cactus on a light wood desk.", caption: "The release notes are written at the studio desk." },
];
---
<!-- Two side by side from a 42rem gallery; the odd last photo runs across both. -->
<div class="mx-auto max-w-6xl px-6 py-10">
<CaseGallery images={images} />
</div>Full width
layout="full": one photo per row, each 16/9 unless it sets its own ratio.
This preview did not load.
full.astro
examples/casegallery/full.astro
---
import CaseGallery from "@astronomic/ui-pro/components/CaseGallery.astro";
// Your own photos.
import concrete from "../../photos/concrete-slab.webp";
import stairway from "../../photos/white-stairway.webp";
const images = [
{ src: concrete, alt: "A concrete building against a pale sky." },
{ src: stairway, alt: "A white stairwell seen from above.", caption: "The library's stair, where the new signs start." },
];
---
<!-- layout="full": one photo per row, each 16/9 unless it sets its own ratio. -->
<div class="mx-auto max-w-6xl px-6 py-10">
<CaseGallery images={images} layout="full" />
</div>Minimal · Light