shadcn.io is an independent project built on shadcn/ui
On this page5 sections
Installation
Overview
Read a district's age mix at a glance, with this demographic overlay map for React with Base UI. Cohortlane, a planning analytics tool, draws the ten districts of Barcelona at their real borders on a live Map that follows your theme, light or dark, and gives each one a small glyph of three bars: its shares under 18, from 18 to 64, and 65 and over. A Toggle Group in the dock under the map picks the band that fills the districts, in five equal steps across that band's range on the theme's chart ramp, and darkens that band's bar in every glyph, so you compare one band without losing the other two. Choosing a district, on the map, by its glyph or in the cells under the dock, outlines it and fills the card floating over the sea with its three shares, rounded by largest remainder so they add to 100. The cells give every district's share for the band and mark the highest and the lowest with a Badge. Built from Map, Toggle Group, Badge and Guides. For city planners, housing teams and public health dashboards.
FAQ
How are the shares rounded?
sharesOf turns each district's three head counts into whole percents that always add to 100: it floors the exact shares, then hands the missing points to the bands with the largest remainders. The card, the glyph and the cells read the same three numbers, so they never disagree by a point.
How are the five fill steps chosen?
For the chosen band, stepOf splits the range from the lowest district's share to the highest into five equal steps, so the darkest fill is always the highest district and the lightest the lowest. The legend in the dock gives the share each step starts at, and on a dark map stepColorOf turns the chart ramp round so the highest step is the brightest; the legend turns with the page's theme.
How are the glyphs drawn?
Each glyph is a marker of three CSS bars, sized by a variable from the district's shares against a common top of 75 percent, so a tall bar means the same in every district. The chosen band's bar is solid and the other two are faint; the chosen district's glyph turns inverted. On a phone the share figure beside the bars is dropped to keep ten glyphs apart.
Where do the borders and counts come from, and what stays local?
The district borders come from OpenStreetMap, simplified to under 40 points each with their shared edges kept, and typed into RINGS; the head counts in LINES are sample figures, not the city's statistics. The basemap tiles come from CARTO over OpenStreetMap data. Nothing is fetched besides the tiles, and nothing you choose is sent or saved.
Can I use it without a mouse?
Yes. The bands are a toggle group, and each district is a button in the cells under the dock with its pressed state; the zoom buttons work from the keyboard, and the map takes the arrow keys and plus and minus once focused. The glyphs and the district shapes are a pointer shortcut to the same choice. A polite message names the highest and lowest district and the chosen district's three shares once the choice settles.
How does it look on a phone?
The map comes first with smaller glyphs, then the chosen district's card docks under it instead of floating over the sea, then the band toggle with its legend and the ten districts in two columns. Scrolling the page over the map scrolls the page; use two fingers to pan it.





