shadcn.io is not affiliated with official shadcn/ui
Image Comparison Slider Gallery Block for Ark UI
A graded drawn picture revealed over its original by a handle you drag or a slider you step, with Original and Graded labels, a percent readout and a picker of three pictures.
Installation
Overview
An image-comparison wipe for React with Ark UI, for Dimroom, a photo editor. A centred header sits over one wide framed picture with + marks on its corners. A graded copy of the picture is laid over the original and shown from the start edge to a handle, with a Graded label at one corner and an Original label at the other. Drag anywhere on the picture to move the handle, or use the slider in the band under it: the arrow keys move it 1%, Page Up and Page Down 10%, Home and End jump to the edges, and a readout says how much is graded. A row of three buttons (Lake, Skyline, Table) swaps the picture and keeps the reveal where it was. The grade is a CSS filter over the same drawing, so the two sides differ only in contrast, and the pictures are drawn in the theme's greys, never photographs. It's built from Slider, Toggle Group, Badge and Guides.
FAQ
Can I drag the picture, and does it work by touch?
Yes. A transparent range input covers the picture, so a mouse drag, a finger drag and a tap all place the handle; vertical swipes still scroll the page. That input is hidden from assistive technology and skipped by Tab; the labelled slider in the band is the accessible control and always shows the same value.
Which keys work, and what is announced?
Tab to the slider ("Graded reveal"), then the arrow keys for 1%, Page Up and Page Down for 10%, Home and End for the edges. It is spoken as "62 percent graded, 38 percent original". Changing the picture is announced in a polite line.
What happens in a right-to-left page?
The picture and the slider stay in the same order in every direction, since a before-and-after is a drawing, not text, so the graded side is always at the picture's left. On the Ark build the arrow keys follow the page direction while the handle does not, so use Home and End or Page Up when an RTL page matters.
How is the grade drawn?
Both sides are the same drawing. The original gets a lower contrast and a lifted brightness through a CSS filter; the graded side gets more contrast and deeper shadows, and a clip shows it up to the handle. Swap the filters for your own edited image where the code comment says so.
Related
- Stepped Before and After GalleryCompare, crop and zoom
- A/B Vote Comparison GalleryCompare, crop and zoom
- Resizable Split Comparison GalleryCompare, crop and zoom
- Full-Width Before After Slider HeroInteractive demos
- Drag Handle Responsive Comparator FeaturesLive controls
- Before After Visual FeaturesProof and comparisons