Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Panorama Viewer Gallery Block for React

A drawn alpine valley seven times wider than tall in a framed scroll region you can drag or scroll with the arrow keys, with a minimap that follows the view, a zoom slider from 100% to 300% and a Reset button.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A panorama viewer for React with Base UI, for Summitry, a summit-photo atlas. One drawn alpine valley, seven times wider than tall (two ranges with snow, a lake that mirrors them, forest on both banks and a hut), sits in a framed scroll region. Drag it with a mouse or pen, scroll it, or focus it and use the arrow keys. A ruled band under the frame holds a minimap, the whole picture small with a rectangle that follows the view (click or drag it to pan), a Zoom slider from 100% to 300%, minus and plus buttons (the only zoom control on a phone), the zoom's value and a Reset button. Zooming keeps the centre of the view where it was. Nothing moves by itself. The picture is drawn, not photographed. It's built from Slider, Button and Guides, with a native scroll region, and your theme's tokens for every colour. The valley and the atlas are made up for the example.

FAQ

How do I move around the picture?

Four ways. Drag it with a mouse or pen. Scroll it with a wheel, a trackpad or a touch swipe. Focus it (it has a tab stop and a visible focus ring) and use the arrow keys, Home and End. Or click or drag on the minimap, which puts that point at the centre of the view.

How does zoom work?

The picture's width and height are the window's height times the zoom, so at 100% the whole valley fits the window's height and at 300% it is three times larger both ways, with the region scrolling in both directions. The block remembers the point the view was centred on and puts it back after the picture resizes. The slider, the minus and plus buttons (twenty percent a press) and Reset all go through one handler, and a polite status line says "Zoom 140%".

What does the minimap show?

The same drawing, small, with a rectangle for the part you are looking at. The rectangle moves as you scroll and changes size as you zoom; its position is written straight to the element as CSS variables from the scroll position, so scrolling never re-renders the picture. The minimap is a pointer extra and is hidden from assistive technology: the scroll region and the zoom controls do everything it does.

How does the zoom slider work per library?

It is a labelled slider from 100 to 300 in steps of ten, with the value read out as "140%". The Slider is named by an aria-labelledby pointing at its hidden label and reads its value through getAriaValueText(formatted, value).

What changes on a phone?

The viewer is shorter, the slider is hidden and the minus and plus buttons stay, together with the minimap and Reset. A touch drag scrolls the region natively.

How do I use my own panorama?

Replace the Scene in the scroll region (and in the minimap) with <img alt="" className="size-full object-cover" src={…} /> of a photograph about seven times wider than tall; change RATIO and the 7 in the width to its proportions. The comment above Scene says where.

  • Pro

    Zoom and Pan Viewer Gallery

    Compare, crop and zoom

    A framed viewport onto one large drawn city plan that you zoom and pan by buttons, a slider, keys, drag, double-click, Control or Command with the wheel, and a two-finger pinch.

  • Pro

    Ken Burns Slideshow Gallery

    Carousels and slides

    A framed viewer that runs rail to rail with five drawn stills, each panning and zooming slowly for seven seconds before crossfading to the next, with a caption, segments that fill with the time, Previous, Next and a visible Pause.

  • Pro

    Band Layout Gallery

    Rows and bands

    Four full-width cinematic bands of one drawn valley at dawn, noon, dusk and night, each drifting as it crosses the screen, with a caption and a Read the note disclosure under every band.

  • Pro

    Image Comparison Slider Gallery

    Compare, crop and zoom

    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.

  • Pro

    Carousel Gallery

    Carousels and slides

    Nine drawn trail pictures in a ruled band for a trail-guide app, three wide with the next one cut off at the rail, turned with buttons, dots and the arrow keys, under a heading row with a live counter.

  • Pro

    A dot-grid world map with a numbered pin on each of six regions, where choosing a region from the list under it rings its pin and rolls the edge locations, latency and uptime to that region.