Nectar UI/
Organism
Embla Carousel • Dual Sync • ResponsiveProduct Gallery.
A synchronized dual-carousel system designed for high-fidelity commerce experiences. It manages viewport-dependent layouts (thumbnails placement) and seamless state synchronization.
import { ProductGallery } from "@/components/docs/product-gallery"Square Ratio • Grid Layout
Dual-Instance Synchronization
We run two separate Embla instances: 'Main' and 'Thumbs'. The tricky part is ensuring that swiping the main image updates the active thumbnail state, and clicking a thumbnail scrolls the main image. This is handled via event listeners on the `select` and `reInit` API hooks.
Responsive Orientation Strategy
Instead of Javascript-heavy resize listeners to change the carousel orientation, we use CSS Grid/Flexbox to reorder the DOM. Thumbnails sit on the left for desktop (flex-row) and move to the bottom for mobile (flex-col-reverse parent or order utilities), preserving the touch-drag axis.
ProductPage.tsx