How to build an accessible Comparison in React

The divider is a role="slider" with aria-valuemin/max/now and full keyboard support (Arrow/Home/End/PageUp/PageDown); aria-orientation reflects the axis so the value and direction are conveyed without sight

When to use a Comparison

When not to use it

Keyboard interactions

Role slider, verified at WCAG 2.2-AA.

Common mistakes

Avoid: <Comparison before={<Before />} after={<After />} /> with no label

Prefer: <Comparison label="Reveal edited photo" before={<Before />} after={<After />} />

The divider is a slider; without a label assistive tech announces an unnamed control

Example

<Comparison before={<img src="/edited.jpg" alt="" />} after={<img src="/original.jpg" alt="Original" />} label="Reveal edited image" />

See the full Comparison reference →