Before After

Two pictures of the same view, one over the other, with a handle to wipe between them.

The same pour in a flat, low-contrast profile, before grading.A slender stream of coffee pours into the cobalt cup.
Shot on the Halden R. Drag the handle to see the in-camera grade.
import { BeforeAfter } from '@brand-studio/ui';
import { pour, pourFlat } from '@/demos/assets';

export default function BeforeAfterDemo() {
  return (
    <figure style={{ width: '100%', maxWidth: 720, margin: 0 }}>
      <BeforeAfter label="Compare the flat profile with Halden colour" before={pourFlat} after={pour} beforeLabel="Flat" afterLabel="Halden colour" />
      <figcaption style={{ marginTop: 12, fontSize: 14, color: 'var(--bs-muted)' }}>Shot on the Halden R. Drag the handle to see the in-camera grade.</figcaption>
    </figure>
  );
}

Installation

pnpm add @brand-studio/ui

Usage

import { BeforeAfter } from '@brand-studio/ui';
<BeforeAfter label="Compare the flat profile with Halden colour" before={flat} after={graded} beforeLabel="Flat" afterLabel="Halden colour" />

Use two images of the same size and framing. initial sets where the handle starts, from 0 to 100.

Accessibility

  • The handle is a native range input: arrow keys, Page Up and Page Down, Home and End all move it, and screen readers announce the position.
  • Both images keep their alt text.
  • A sideways drag moves the handle on touch; vertical swipes still scroll the page.

API Reference

PropTypeDefault
beforeImageAsset–
afterImageAsset–
label?string'Compare images'
beforeLabel?string'Before'
afterLabel?string'After'
initial?number50
className?string''

Still, Deskhand and Hollis are fictional brands. The coffee photographs are original generated artwork. @brand-studio/ui is MIT licensed.