Image Compare
A before/after comparison on one layout-stable stage, driven by a native range input so it works with a mouse, a keyboard and a screen reader.
Both images share one stage, so the block never jumps while the two files load. The split is a native range input rather than a decorative handle: arrow keys move it, the value is announced, and the visual divider follows the same state.
Preview


Installation
Add the item with the shadcn CLI, or copy the source manually.
pnpm dlx shadcn@latest add litingyes/blocove/image-compareRequires a shadcn/ui project set up with Base UI primitives. Blocove is developed against the b0 preset, but it installs no base config or theme tokens: your own preset, fonts and colors stay in place.
Or install from the namespace after adding the registry: npx shadcn@latest add @blocove/image-compare
API Reference
Props accepted by the exported components.
ImageCompare
A before/after comparison on one layout-stable stage. The range input drives the split and stays visible for keyboard and screen-reader users.
| Prop | Type | Default |
|---|---|---|
before | ImageCompareSide | Required |
after | ImageCompareSide | Required |
beforeLabel | string | 'Before' |
afterLabel | string | 'After' |
defaultPosition | number | 50 |
aspectRatio | number | string | '16 / 9' |
widths | readonly number[] | - |
transform | (src, width) => string | Identity |
sizes | string | - |
rangeLabel | string | 'Comparison position' |
className | string | - |
ImageCompareSide
One side of the comparison.
| Prop | Type | Default |
|---|---|---|
src | string | Required |
alt | string | Required |