Skip to content

shadcn.io is an independent project built on shadcn/ui

Hiking Trail Elevation Map Block for React

Four real paths up Yr Wyddfa on a live map, their profiles on one scale, and a slider that walks a dot along the chosen path with height and slope.

On this page5 sections

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

Read a climb before you lace up, with this hiking trail map for React with Base UI. Cairnpath, a trail guide, lays four real paths up Yr Wyddfa (Snowdon), the Llanberis Path, the Pyg Track, the Rhyd Ddu Path and the Watkin Path, on a live Map that follows your theme, each routed along OpenStreetMap's footpaths with a height every fortieth of the way from a terrain model. A Toggle Group over the map picks the path and flies the camera to it, while the other three stay dashed and answer a click. Under the map the four elevation profiles share one scale in kilometres and metres, so the long, gentle path and the steep one read side by side, and a Slider named "Position on trail" moves a dot along the chosen path, the walked part in the primary colour, and a cursor along its profile, reading "Km 2.7, 612 m, +14%". Six cells give the length, the climb, the start, the time up by Naismith's rule and what is still to walk and to climb, all derived from the same points, with the grade as a Badge. Built from Map, Toggle Group, Slider, Badge and Guides. For hiking guides, national parks and running clubs.

FAQ

Where do the paths and heights come from?

Each path was routed once on foot along OpenStreetMap's paths, simplified to under 80 points and baked into SPECS with 41 heights from the Copernicus 90 m terrain model, lightly smoothed; nothing is fetched at runtime except the map's tiles. A 90 m grid rounds the summit off, so the profiles top out near 1,030 m while the cairn stands at 1,085 m, and the caption says so. Cairnpath and its grades are invented.

What is derived, and how?

The length is the sum of the route's legs on a sphere, the climb is every rise between neighbouring heights, and the time up is Naismith's rule: 12 minutes a kilometre plus one for every 10 m of climb. At the slider, readOf reads the height between two samples and the slope of that stretch, and climbLeft adds the rises still ahead, so no figure is typed twice.

Why do the profiles share one scale?

So paths can be compared at a glance: kilometres run across to the longest path and metres run up to 1,100 m for all four, and the chosen profile is drawn over the others. A short, steep path ends early and climbs fast; a long one rises slowly across the whole width.

Can I use it without a mouse?

Yes. The paths are a toggle group, and the slider moves a tenth of a kilometre per arrow key and speaks the place, the height and the slope; the zoom buttons and the map itself (arrow keys, plus and minus) work once focused. A click on a dashed path on the map is a pointer shortcut to the same choice, and a polite message reads the new position once the slider settles.

How does it look on a phone?

The map comes first with the four paths in a bar over it, then the profile, the slider and the six cells in two columns. The page scrolls over the map; two fingers pan it.

Can I plan a real walk with it?

Not on its own. The paths and heights are real, but the grades are invented, the times are a rule of thumb and the weather on the mountain changes fast. Use a proper map and forecast, and treat this as a demo of how a trail guide could show a climb.