---
title: "before-after"
description: "Two pictures at the same size, labelled Before and After, under a title that states what changed."
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/deckster/llms.txt
> Use this file to discover all available pages before exploring further.

# before-after

The `before-after` layout sets two pictures side by side at the same size, each with a label, under a title that states what changed. Use it for a redesign, a restoration or any visual evidence of a change, where seeing both states does more than a list of differences.

> **New in v0.6.0**
>
> The `before-after` layout needs `@deckster/cli` 0.6.0 or later. In 0.5.0, `deck lint` reports `layout: There is no "before-after" layout.`

## Example

[Live slide: "The bollards stopped vans, not deliveries", slide 138 of the lookbook deck](https://sandrinodm.github.io/deckster/decks/lookbook/#/before-after-street)

`decks/lookbook/slides/before-after-street.mdx`:

```mdx
---
layout: before-after
title: The bollards stopped vans, not deliveries
eyebrow: Kestwick Old Town
before:
  src: ../assets/scenes/van-at-the-bollards.svg
  alt: A delivery van waiting outside the bollards at the entrance to Kestwick Old Town
  caption: Old Town entrance, before the loop
  focal: center 50%
after:
  src: ../assets/scenes/hub-square.svg
  alt: Cargo bikes serving the Old Town square from Wrenhaul's neighbourhood hub
  caption: Old Town hub, ready for the morning
  focal: center 50%
fit: cover
reveal: true
budget: 40s
---

A neighbourhood hub puts the last mile on the right side of the bollards.

<Footnote>Illustrated scenes of Kestwick Old Town; Wrenhaul and its service are fictional.</Footnote>

<Notes>
`before-after` with `fit: cover`, captions and an accented after label, revealed before first; use it when two pictures show the change more clearly than a list.
[click] Before: the van reaches the bollards and stops. The shop still has a delivery to make.
[click] After: a small hub inside the Old Town sends cargo bikes straight to the door. The restriction becomes the reason the network works.
</Notes>
```

`before:` and `after:` each name a picture with `src` and `alt`, and add an optional `caption`. `fit: cover` crops both pictures to equal frames around each side's `focal` point. The labels default to "Before" and "After", and the after label carries an arrow and the accent colour. With `reveal: true` the before picture comes in first and the after picture on the next click. The body is one sentence on what to compare.

*Slide still: Two phone screens of a rider app side by side on a deep green slide, labelled Loop planned and Next stop, each shown whole on a dark panel with a one-line caption under it.* [Open the slide](https://sandrinodm.github.io/deckster/decks/lookbook/#/before-after-rider)

`fit: contain` shows each picture whole, which suits screenshots, and `treatment: plain` keeps them in their own colours. This slide also renames the labels and sets `accent: none`, so neither label is coloured.

## When to use it

- **Two pictures of one change.** A `before` and an `after` are both required, each with `alt` of up to 120 characters. A `label` takes up to 20 characters and a `caption` up to 48, on one line. The title takes up to 50 characters, the body up to 14 words and the footnote up to 16.
- **Say what changed in the title.** Labels always name the sides, so colour never carries the change by itself. `accent: none` makes the labels neutral, and on an `accent` surface the after label uses the foreground colour instead of the accent.
- **Choose `contain` or `cover` once.** Both pictures share `fit`. `contain` is the default and shows them whole. With `cover`, add `focal` (`top`, `center 30%` or `40% 20%`) to say what to keep when a picture is cropped. Without `treatment`, `contain` shows plain pictures and `cover` uses the brand's default treatment; [fonts and assets](https://sandrinodm.github.io/deckster/brands/fonts-and-assets/) lists the treatments.
- **Reveal the change.** `reveal: true` brings in the before picture, then the after picture. Put a `[click]` cue for each in the notes. See [builds](https://sandrinodm.github.io/deckster/write-slides/builds/).
- **Files live in the deck folder.** [Media](https://sandrinodm.github.io/deckster/write-slides/media/) explains how `src` paths resolve.

## Reference

Frontmatter: `layout: before-after`; surface: the deck's default; title: required, 50 characters at most; PowerPoint: two-content slide.

Two pictures side by side at the same size, labelled Before and After, under a title that states what changed. Each side has a required file and accessible description, an optional label and a one-line caption below the picture. Both pictures share `fit`: contain shows them whole (the default), cover crops them into equal frames around each side's focal point. The after label carries the accent unless `accent: none`; labels always name the sides so colour alone never carries the change. `reveal: true` brings in before first, then after. Use it for a redesign, a restoration or visual evidence of a change. Use gallery for an unpaired collection with a lead picture, screen for one interface with callouts, and shift when the change is an argument in words and figures rather than two pictures.

*Slide still (a lookbook slide in this layout, not the example below): A slide in the before-after layout: The bollards stopped vans, not deliveries.* [Open the slide](https://sandrinodm.github.io/deckster/decks/lookbook/#/before-after-street)

**Slots**

| Slot | Required | Takes | Budget | What goes in it |
| --- | --- | --- | --- | --- |
| `body` | no | text | 14 words | One sentence under the title explaining what to compare between the pictures. |
| `<Footnote>` | no | text | 16 words | A source, date or qualification on the bottom line. |

**Frontmatter fields**

| Field | Values | How to use it |
| --- | --- | --- |
| `eyebrow` | text | Write a few words of at most 40 characters, for example `eyebrow: Budget committee`, or leave it out. |
| `before` (required) | text | Name the earlier picture with `src` (a file in the deck folder) and `alt` (up to 120 characters). Optionally add `label` (up to 20 characters, default "Before"), `caption` (one line, up to 48 characters), and `focal`. Name the part of the photo to keep when it is cropped, as a CSS position: `focal: top`, `focal: center 30%` (a face in the upper third) or `focal: 40% 20%`. |
| `after` (required) | text | Name the later picture with `src` (a file in the deck folder) and `alt` (up to 120 characters). Optionally add `label` (up to 20 characters, default "After"), `caption` (one line, up to 48 characters), and `focal`. Name the part of the photo to keep when it is cropped, as a CSS position: `focal: top`, `focal: center 30%` (a face in the upper third) or `focal: 40% 20%`. |
| `fit` | `contain` (default), `cover` | Use `contain` (the default) to show both pictures whole, or `cover` to crop both to fill equal frames. |
| `accent` | `after` (default), `none` | Use `accent: none` for neutral labels; by default the after label uses accent text, or foreground text on an accent slide. |
| `treatment` | text | Name one of the brand's image treatments, for example `treatment: plain` (every brand has it) to show a screenshot, map or chart in its own colors; `deck brand --json` lists them under imagery.treatments. With contain, omitted treatment defaults to plain; cover uses the brand default. |
| `reveal` | `true`, `false` (default) | Write `reveal: true` to show the items one per step, in order, or leave it out to show them all at once. |
| `chrome` | `true` (default), `false` | Write `chrome: false` to hide the page number, logo and progress bar on this slide, or `chrome: true` to show them. |

**Example**

```mdx
---
layout: before-after
title: The same street now has summer shade
before:
  src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='1000'%3E%3Crect width='1600' height='1000' fill='%238fa79a'/%3E%3C/svg%3E"
  alt: Harrow Road before the planting programme
  caption: "Harrow Road, before planting"
after:
  src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='1000'%3E%3Crect width='1600' height='1000' fill='%238fa79a'/%3E%3C/svg%3E"
  alt: Harrow Road three summers after planting
  caption: "Harrow Road, three summers later"
---

<Notes>Compare the same stretch of pavement before and after planting.</Notes>
```

## Common mistakes

- **A picture without a description.** `alt` is required on both sides:

  ```console
  $ deck lint launch-review
  decks/launch-review/slides/ba-alt.mdx
    error   schema (ba-alt): before.alt is required.
            Fix: Name the earlier picture with `src` (a file in the deck folder) and `alt` (up to 120 characters). Optionally add `label` (up to 20 characters, default "Before"), `caption` (one line, up to 48 characters), and `focal`. Name the part of the photo to keep when it is cropped, as a CSS position: `focal: top`, `focal: center 30%` (a face in the upper third) or `focal: 40% 20%`.

  launch-review: 1 error, 0 warnings.
  ```

- **A long label or caption.** A label over 20 characters is a `schema` error: `before.label: Expected a picture label of at most 20 characters, got "The old delivery route …" (38 characters).` A caption over 48 fails the same way.
- **A picture that is not there.** A wrong path is a `media-missing` error: "`before.src: ../assets/van-at-the-bollards.svg` does not exist". The layout draws an empty panel until the file is there.
- **Comparing pictures that differ in shape.** `fit: cover` crops both to the same frame. Check each with `deck shot` and set `focal` on the side that loses what matters.

## Related layouts

- [`gallery`](https://sandrinodm.github.io/deckster/reference/layouts/gallery/): an unpaired collection of pictures with a lead picture.
- [`screen`](https://sandrinodm.github.io/deckster/reference/layouts/screen/): one interface with callouts.
- [`shift`](https://sandrinodm.github.io/deckster/reference/layouts/shift/): a change argued in words and figures rather than two pictures.

Source: https://sandrinodm.github.io/deckster/reference/layouts/before-after/index.mdx
