shadcn.io is an independent project built on shadcn/ui
On this page5 sections
Installation
Overview
Keep the big picture in a corner while you read the streets, with this overview inset map for React with Base UI. Kerbmile, a road-race organiser, draws the Harbour Half, a 21.1 km loop through Copenhagen from Rådhuspladsen, on a live street-level Map that follows your theme, light or dark, with a marker at every kilometre and a droplet at each of the four water stations. A second, small map in the corner holds the whole loop and a box that is the street map's view: it moves and resizes as you pan and zoom. Press anywhere on the overview to bring the street map there, or take hold of the box and drag it round the course; the street map follows the pointer at its own zoom. The card lists the checkpoints, each a button that flies the street map to its kilometre, and reads the stretch of course in view ("km 4.2 to 6.8 in view") from the same box. Built from Map and Guides. For race and event maps, trails, tours, survey sites and any map people read up close but need to place in a larger area.
FAQ
How does the box follow the street map?
A small ViewWatcher inside the street map reads its corners, middle and zoom on every frame it moves and when it's resized. The overview draws those corners as a GeoJSON polygon with MapGeoJSON, so the box moves and grows or shrinks with every pan and zoom, from the buttons, the keyboard or the pointer.
What happens when I drag on the overview?
The overview has its own panning turned off (interactive: false), and a helper reads where the pointer presses and moves on it. A press inside the box keeps the spot you took hold of under the pointer; a press outside brings the box's middle there. Each point aims the street map's MapCamera with no flight, at its current zoom, so the street map follows the pointer.
Can I use it without a mouse?
Yes. Each checkpoint in the card is a button that flies the street map to its kilometre; the street map takes the arrow keys and plus and minus once focused, and the zoom buttons work from the keyboard. The overview is a picture of where you are: the box moves with every move you make, and a polite message says which kilometres are in view once the map settles.
Where does the course come from, and what stays local?
The loop was routed once along Copenhagen's real streets with OpenStreetMap's foot routing (OSRM), simplified and typed into the file. The kilometre markers sit at their share of the line (MapRouteMarker at), and the stretch in view is worked out from the same points. Kerbmile, the race, its date and its stations are invented. Nothing is fetched or saved but the map tiles.





