Skip to content

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

Walkability Score Map Block for React

A flat in Barcelona with 5, 10 and 15 minute walking rings on a live map; fourteen places walked along real streets add up to a walk index out of 100.

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

Score a neighbourhood by what you can reach on foot, with this walkability map for React with Base UI. Pacestone, a neighbourhood index, scores a flat on Carrer de la Perla in Gràcia, Barcelona, against fourteen places round it in five categories (groceries, transit, parks, cafés and schools), each at its real place on a live Map that follows your theme, light or dark. Every walk was routed once along the real streets and baked into the file, so a place's minutes are its route over a typed pace of 80 metres a minute, rounded up. A Toggle Group in the band under the map picks a walk of 5, 10 or 15 minutes and the map draws that ring round the home in a still frame; places whose walk fits turn solid, the rest dashed. A place counts for a full point at the door and half at the limit, each category scores what it gathers over a typed target, and the index is the five scores times their shares of 100: 40 at 5 minutes, 82 at 10, 92 at 15. Five cells under the band show each category's points as a bar and list its places with their walk; choosing one draws its route on the map and flies there. Built from Map, Toggle Group and Guides. For rental sites, estate agents, relocation guides and city planners.

FAQ

How is the index worked out?

weightOf gives a place whose walk fits the time 1 - 0.5 * (minutes / ring) and nothing otherwise. scoreOf adds a category's weights and divides by its target, capped at 1, and walkIndexOf multiplies each score by the category's share of 100 and rounds. It is this demo's formula, not a published one, and the caption says so; tune CATEGORIES for the weights and targets that suit your market.

Are the walking times real?

The routes are: each place's walk was asked of an OpenStreetMap foot router once, when the block was written, simplified and typed into LINES with its length in metres. Nothing is routed while the page runs. The minutes assume a steady 80 metres a minute and ignore crossings, stairs and hills; in your app call a walking-route service for the home the person chose.

Why does a place inside the ring say too far?

The ring is straight-line reach at the same pace, drawn for a sense of scale, while a place counts by its walk along the streets. Lesseps station sits inside the 10-minute ring as the crow flies, but the streets make it a 12-minute walk, so it does not count until 15 minutes. That gap is the point of routing the walks.

Can I use it without a mouse?

Yes. The walk time is a toggle group that takes the arrow keys, every place is a button with a pressed state in its category's list, and the zoom buttons work from the keyboard; the map itself takes the arrow keys and plus and minus once focused. The badges on the map are a pointer shortcut to the same places. A polite message gives the index, the places counted and the chosen walk once a change settles.

Is the data real, and what stays local?

The streets, the metro stations, the squares, the park and the market are real; the home, the other shops and schools, and Pacestone are invented. Nothing is fetched but the map tiles (CARTO's basemaps over OpenStreetMap data, credited in the corner) and nothing is sent.

How does it look on a phone?

The map comes first with smaller badges, then the walk-time band with the index beside the toggle, then the five categories one under another. Changing the walk time never moves the page, and scrolling the page over the map scrolls the page; two fingers move the map.